bpo-38820: OpenSSL 3.0.0 compatibility. (GH-17190) · python/cpython@2b7de66 · GitHub
Skip to content

Commit 2b7de66

Browse files
tiranmiss-islington
authored andcommitted
bpo-38820: OpenSSL 3.0.0 compatibility. (GH-17190)
test_openssl_version now accepts version 3.0.0. getpeercert() no longer returns IPv6 addresses with a trailing new line. Signed-off-by: Christian Heimes <christian@python.org> https://bugs.python.org/issue38820
1 parent 15fb7fa commit 2b7de66

4 files changed

Lines changed: 59 additions & 7 deletions

File tree

Doc/library/ssl.rst

Lines changed: 3 additions & 0 deletions

Lib/test/test_ssl.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ def test_parse_cert_CVE_2013_4238(self):
488488
('email', 'null@python.org\x00user@example.org'),
489489
('URI', 'http://null.python.org\x00http://example.org'),
490490
('IP Address', '192.0.2.1'),
491-
('IP Address', '2001:DB8:0:0:0:0:0:1\n'))
491+
('IP Address', '2001:DB8:0:0:0:0:0:1'))
492492
else:
493493
# OpenSSL 0.9.7 doesn't support IPv6 addresses in subjectAltName
494494
san = (('DNS', 'altnull.python.org\x00example.com'),
@@ -515,7 +515,7 @@ def test_parse_all_sans(self):
515515
(('commonName', 'dirname example'),))),
516516
('URI', 'https://www.python.org/'),
517517
('IP Address', '127.0.0.1'),
518-
('IP Address', '0:0:0:0:0:0:0:1\n'),
518+
('IP Address', '0:0:0:0:0:0:0:1'),
519519
('Registered ID', '1.2.3.4.5')
520520
)
521521
)
@@ -542,11 +542,11 @@ def test_openssl_version(self):
542542
# Some sanity checks follow
543543
# >= 0.9
544544
self.assertGreaterEqual(n, 0x900000)
545-
# < 3.0
546-
self.assertLess(n, 0x30000000)
545+
# < 4.0
546+
self.assertLess(n, 0x40000000)
547547
major, minor, fix, patch, status = t
548-
self.assertGreaterEqual(major, 0)
549-
self.assertLess(major, 3)
548+
self.assertGreaterEqual(major, 1)
549+
self.assertLess(major, 4)
550550
self.assertGreaterEqual(minor, 0)
551551
self.assertLess(minor, 256)
552552
self.assertGreaterEqual(fix, 0)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make Python compatible with OpenSSL 3.0.0. :func:`ssl.SSLSocket.getpeercert`
2+
no longer returns IPv6 addresses with a trailing new line.

Modules/_ssl.c

Lines changed: 48 additions & 1 deletion

0 commit comments

Comments
 (0)