diff options
author | Grant Ramsay <grant.ramsay@hotmail.com> | 2023-11-29 00:15:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-29 00:15:39 (GMT) |
commit | e413daf5f6b983bdb4e1965d76b5313cb93b266e (patch) | |
tree | 1a6e410e4c910cf75e2016a687668bc4da8843d4 /Lib | |
parent | 48dfd74a9db9d4aa9c6f23b4a67b461e5d977173 (diff) | |
download | cpython-e413daf5f6b983bdb4e1965d76b5313cb93b266e.zip cpython-e413daf5f6b983bdb4e1965d76b5313cb93b266e.tar.gz cpython-e413daf5f6b983bdb4e1965d76b5313cb93b266e.tar.bz2 |
gh-112454: Disable TLS-PSK if OpenSSL was built without PSK support (#112491)
If OpenSSL was built without PSK support, the python TLS-PSK
methods will raise "NotImplementedError" if called.
Add a constant "ssl.HAS_PSK" to check if TLS-PSK is supported
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ssl.py | 2 | ||||
-rw-r--r-- | Lib/test/test_ssl.py | 2 |
2 files changed, 3 insertions, 1 deletions
@@ -116,7 +116,7 @@ except ImportError: from _ssl import ( HAS_SNI, HAS_ECDH, HAS_NPN, HAS_ALPN, HAS_SSLv2, HAS_SSLv3, HAS_TLSv1, - HAS_TLSv1_1, HAS_TLSv1_2, HAS_TLSv1_3 + HAS_TLSv1_1, HAS_TLSv1_2, HAS_TLSv1_3, HAS_PSK ) from _ssl import _DEFAULT_CIPHERS, _OPENSSL_API_VERSION diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index aecba89..3fdfa29 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -4259,6 +4259,7 @@ class ThreadedTests(unittest.TestCase): 'Session refers to a different SSLContext.') @requires_tls_version('TLSv1_2') + @unittest.skipUnless(ssl.HAS_PSK, 'TLS-PSK disabled on this OpenSSL build') def test_psk(self): psk = bytes.fromhex('deadbeef') @@ -4326,6 +4327,7 @@ class ThreadedTests(unittest.TestCase): s.connect((HOST, server.port)) @requires_tls_version('TLSv1_3') + @unittest.skipUnless(ssl.HAS_PSK, 'TLS-PSK disabled on this OpenSSL build') def test_psk_tls1_3(self): psk = bytes.fromhex('deadbeef') identity_hint = 'identity-hint' |