diff --git a/base/common/python/pki/client.py b/base/common/python/pki/client.py index 9b476a73e04..87537519bbe 100644 --- a/base/common/python/pki/client.py +++ b/base/common/python/pki/client.py @@ -95,9 +95,9 @@ def __init__(self, pool_connections=DEFAULT_POOLSIZE, def init_poolmanager(self, connections, maxsize, block=adapters.DEFAULT_POOLBLOCK, **pool_kwargs): - context = ssl.SSLContext( - ssl.PROTOCOL_TLS # pylint: disable=no-member - ) + + tls_version = ssl.PROTOCOL_TLS_CLIENT if hasattr(ssl, "PROTOCOL_TLS_CLIENT") else ssl.PROTOCOL_TLS + context = ssl.SSLContext(tls_version) # Enable post handshake authentication for TLS 1.3 if getattr(context, "post_handshake_auth", None) is not None: @@ -116,9 +116,7 @@ def init_poolmanager(self, connections, maxsize, for capath in self.capaths: context.load_verify_locations(capath=capath) - if self.verify: - # Enable certificate verification - context.verify_mode = ssl.VerifyMode.CERT_REQUIRED # pylint: disable=no-member + context.verify_mode = ssl.VerifyMode.CERT_REQUIRED # pylint: disable=no-member pool_kwargs['ssl_context'] = context return super().init_poolmanager(