Skip to content

Commit

Permalink
Replace deprecated ssl.PROTOCOL_TLS in pki/client.py
Browse files Browse the repository at this point in the history
Resolves #4512
  • Loading branch information
ckelleyRH committed Jul 31, 2023
1 parent cb798fc commit 745af6e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions base/common/python/pki/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(
Expand Down

0 comments on commit 745af6e

Please sign in to comment.