Skip to content

Commit 067c372

Browse files
vstinnertiran
andauthored
bpo-46114: Fix OpenSSL version check for 3.0.1 (GH-30170) (GH-92954)
(cherry picked from commit 2985fea) Co-authored-by: Christian Heimes <[email protected]>
1 parent 6d4927a commit 067c372

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

Lib/test/test_ssl.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,17 @@ def test_openssl_version(self):
586586
self.assertLessEqual(patch, 63)
587587
self.assertGreaterEqual(status, 0)
588588
self.assertLessEqual(status, 15)
589-
# Version string as returned by {Open,Libre}SSL, the format might change
590-
if IS_LIBRESSL:
591-
self.assertTrue(s.startswith("LibreSSL {:d}".format(major)),
592-
(s, t, hex(n)))
589+
590+
libressl_ver = f"LibreSSL {major:d}"
591+
if major >= 3:
592+
# 3.x uses 0xMNN00PP0L
593+
openssl_ver = f"OpenSSL {major:d}.{minor:d}.{patch:d}"
593594
else:
594-
self.assertTrue(s.startswith("OpenSSL {:d}.{:d}.{:d}".format(major, minor, fix)),
595-
(s, t, hex(n)))
595+
openssl_ver = f"OpenSSL {major:d}.{minor:d}.{fix:d}"
596+
self.assertTrue(
597+
s.startswith((openssl_ver, libressl_ver)),
598+
(s, t, hex(n))
599+
)
596600

597601
@support.cpython_only
598602
def test_refcycle(self):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix test case for OpenSSL 3.0.1 version. OpenSSL 3.0 uses ``0xMNN00PP0L``.

0 commit comments

Comments
 (0)