-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
There are situations where get_max_tls_protocol()
will get a max openssl version from python ssl
that is higher than what urllib3
supports.
The error will be:
KeyError: 5
in requests/packages/urllib3/contrib/pyopenssl.py:271
on the line with ctx = OpenSSL.SSL.Context(_openssl_versions[ssl_version])
Using the following replacement for docker.ssladapter.ssladapter.get_max_tls_protocol()
worked for me, but there might be other cases I am missing:
from requests.packages.urllib3.contrib import pyopenssl
def get_max_tls_protocol():
protocols = ('PROTOCOL_TLSv1_2',
'PROTOCOL_TLSv1_1',
'PROTOCOL_TLSv1',
for proto in protocols:
if hasattr(ssl, proto):
proto_id = getattr(ssl, proto)
if proto_id in pyopenssl._openssl_versions:
return proto_id