bpo-38275: Fix test_ssl issue caused by GH-16386 (#16428)

Check presence of SSLContext.minimum_version to make tests pass with
old versions of OpenSSL.

Signed-off-by: Christian Heimes <christian@python.org>
This commit is contained in:
Christian Heimes 2019-09-26 18:23:17 +02:00 committed by GitHub
parent df6ac7e2b8
commit 9f77268f90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -190,11 +190,13 @@ def has_tls_version(version):
# be compiled in but disabled by a policy or config option.
ctx = ssl.SSLContext()
if (
hasattr(ctx, 'minimum_version') and
ctx.minimum_version != ssl.TLSVersion.MINIMUM_SUPPORTED and
version < ctx.minimum_version
):
return False
if (
hasattr(ctx, 'maximum_version') and
ctx.maximum_version != ssl.TLSVersion.MAXIMUM_SUPPORTED and
version > ctx.maximum_version
):