[Python-checkins] bpo-46114: Fix OpenSSL version check for 3.0.1 (GH-30170) (GH-92954)

ambv webhook-mailer at python.org
Mon Jun 6 12:46:30 EDT 2022


https://github.com/python/cpython/commit/067c37207449a5315abd6c3b8c0527145b6729b9
commit: 067c37207449a5315abd6c3b8c0527145b6729b9
branch: 3.8
author: Victor Stinner <vstinner at python.org>
committer: ambv <lukasz at langa.pl>
date: 2022-06-06T18:46:16+02:00
summary:

bpo-46114: Fix OpenSSL version check for 3.0.1 (GH-30170) (GH-92954)

(cherry picked from commit 2985feac4e02d590bb78bcce9e30864be53280ac)

Co-authored-by: Christian Heimes <christian at python.org>

files:
A Misc/NEWS.d/next/Tests/2021-12-17-14-46-19.bpo-46114.9iyZ_9.rst
M Lib/test/test_ssl.py

diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 32bb2aa37d320..3e5f1ade0e6b7 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -586,13 +586,17 @@ def test_openssl_version(self):
         self.assertLessEqual(patch, 63)
         self.assertGreaterEqual(status, 0)
         self.assertLessEqual(status, 15)
-        # Version string as returned by {Open,Libre}SSL, the format might change
-        if IS_LIBRESSL:
-            self.assertTrue(s.startswith("LibreSSL {:d}".format(major)),
-                            (s, t, hex(n)))
+
+        libressl_ver = f"LibreSSL {major:d}"
+        if major >= 3:
+            # 3.x uses 0xMNN00PP0L
+            openssl_ver = f"OpenSSL {major:d}.{minor:d}.{patch:d}"
         else:
-            self.assertTrue(s.startswith("OpenSSL {:d}.{:d}.{:d}".format(major, minor, fix)),
-                            (s, t, hex(n)))
+            openssl_ver = f"OpenSSL {major:d}.{minor:d}.{fix:d}"
+        self.assertTrue(
+            s.startswith((openssl_ver, libressl_ver)),
+            (s, t, hex(n))
+        )
 
     @support.cpython_only
     def test_refcycle(self):
diff --git a/Misc/NEWS.d/next/Tests/2021-12-17-14-46-19.bpo-46114.9iyZ_9.rst b/Misc/NEWS.d/next/Tests/2021-12-17-14-46-19.bpo-46114.9iyZ_9.rst
new file mode 100644
index 0000000000000..6878cea032387
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2021-12-17-14-46-19.bpo-46114.9iyZ_9.rst
@@ -0,0 +1 @@
+Fix test case for OpenSSL 3.0.1 version. OpenSSL 3.0 uses ``0xMNN00PP0L``.



More information about the Python-checkins mailing list