@@ -222,13 +222,21 @@ def test_parse_cert_CVE_2013_4238(self):
222222 ((
'emailAddress' ,
'[email protected] ' ),))
223223 self .assertEqual (p ['subject' ], subject )
224224 self .assertEqual (p ['issuer' ], subject )
225- self .assertEqual (p ['subjectAltName' ],
226- (('DNS' , 'altnull.python.org\x00 example.com' ),
227- 228- ('URI' , 'http://null.python.org\x00 http://example.org' ),
229- ('IP Address' , '192.0.2.1' ),
230- ('IP Address' , '2001:DB8:0:0:0:0:0:1\n ' ))
231- )
225+ if ssl ._OPENSSL_API_VERSION >= (0 , 9 , 8 ):
226+ san = (('DNS' , 'altnull.python.org\x00 example.com' ),
227+ 228+ ('URI' , 'http://null.python.org\x00 http://example.org' ),
229+ ('IP Address' , '192.0.2.1' ),
230+ ('IP Address' , '2001:DB8:0:0:0:0:0:1\n ' ))
231+ else :
232+ # OpenSSL 0.9.7 doesn't support IPv6 addresses in subjectAltName
233+ san = (('DNS' , 'altnull.python.org\x00 example.com' ),
234+ 235+ ('URI' , 'http://null.python.org\x00 http://example.org' ),
236+ ('IP Address' , '192.0.2.1' ),
237+ ('IP Address' , '<invalid>' ))
238+
239+ self .assertEqual (p ['subjectAltName' ], san )
232240
233241 def test_DER_to_PEM (self ):
234242 with open (SVN_PYTHON_ORG_ROOT_CERT , 'r' ) as f :
0 commit comments