@@ -208,13 +208,21 @@ def test_parse_cert_CVE_2013_4238(self):
208208 ((
'emailAddress' ,
'[email protected] ' ),))
209209 self .assertEqual (p ['subject' ], subject )
210210 self .assertEqual (p ['issuer' ], subject )
211- self .assertEqual (p ['subjectAltName' ],
212- (('DNS' , 'altnull.python.org\x00 example.com' ),
213- 214- ('URI' , 'http://null.python.org\x00 http://example.org' ),
215- ('IP Address' , '192.0.2.1' ),
216- ('IP Address' , '2001:DB8:0:0:0:0:0:1\n ' ))
217- )
211+ if ssl ._OPENSSL_API_VERSION >= (0 , 9 , 8 ):
212+ san = (('DNS' , 'altnull.python.org\x00 example.com' ),
213+ 214+ ('URI' , 'http://null.python.org\x00 http://example.org' ),
215+ ('IP Address' , '192.0.2.1' ),
216+ ('IP Address' , '2001:DB8:0:0:0:0:0:1\n ' ))
217+ else :
218+ # OpenSSL 0.9.7 doesn't support IPv6 addresses in subjectAltName
219+ san = (('DNS' , 'altnull.python.org\x00 example.com' ),
220+ 221+ ('URI' , 'http://null.python.org\x00 http://example.org' ),
222+ ('IP Address' , '192.0.2.1' ),
223+ ('IP Address' , '<invalid>' ))
224+
225+ self .assertEqual (p ['subjectAltName' ], san )
218226
219227 def test_DER_to_PEM (self ):
220228 with open (SVN_PYTHON_ORG_ROOT_CERT , 'r' ) as f :
0 commit comments