Skip to content

Commit 8f65ef8

Browse files
committed
Issue python#18709: Fix issue with IPv6 address in subjectAltName on Mac OS X Tiger
1 parent 82f8828 commit 8f65ef8

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Lib/test/test_ssl.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,21 @@ def test_parse_cert_CVE_2013_4073(self):
102102
(('emailAddress', 'python-dev@python.org'),))
103103
self.assertEqual(p['subject'], subject)
104104
self.assertEqual(p['issuer'], subject)
105-
self.assertEqual(p['subjectAltName'],
106-
(('DNS', 'altnull.python.org\x00example.com'),
107-
('email', 'null@python.org\x00user@example.org'),
108-
('URI', 'http://null.python.org\x00http://example.org'),
109-
('IP Address', '192.0.2.1'),
110-
('IP Address', '2001:DB8:0:0:0:0:0:1\n'))
111-
)
105+
if ssl._OPENSSL_API_VERSION >= (0, 9, 8):
106+
san = (('DNS', 'altnull.python.org\x00example.com'),
107+
('email', 'null@python.org\x00user@example.org'),
108+
('URI', 'http://null.python.org\x00http://example.org'),
109+
('IP Address', '192.0.2.1'),
110+
('IP Address', '2001:DB8:0:0:0:0:0:1\n'))
111+
else:
112+
# OpenSSL 0.9.7 doesn't support IPv6 addresses in subjectAltName
113+
san = (('DNS', 'altnull.python.org\x00example.com'),
114+
('email', 'null@python.org\x00user@example.org'),
115+
('URI', 'http://null.python.org\x00http://example.org'),
116+
('IP Address', '192.0.2.1'),
117+
('IP Address', '<invalid>'))
118+
119+
self.assertEqual(p['subjectAltName'], san)
112120

113121
def test_DER_to_PEM(self):
114122
with open(SVN_PYTHON_ORG_ROOT_CERT, 'r') as f:

0 commit comments

Comments
 (0)