+ return True
+
+
+class TLSAdapter(requests.adapters.HTTPAdapter):
+ '''Adapt to older TLS stacks that would raise errors otherwise.
+
+ We try to work around different issues:
+ * Enable weak ciphers such as 3DES or RC4, that have been disabled by default
+ in OpenSSL 3.0 or recent Linux distributions.
+ * Enable weak Diffie-Hellman key exchange sizes.
+ * Enable unsafe legacy renegotiation for servers without RFC 5746 support.
+
+ See Also
+ --------
+ https://github.com/psf/requests/issues/4775#issuecomment-478198879
+
+ Notes
+ -----
+ Python is missing an ssl.OP_LEGACY_SERVER_CONNECT constant.
+ We have extracted the relevant value from <openssl/ssl.h>.
+
+ '''
+
+ def __init__(self, verify=True):
+ self.verify = verify
+ super().__init__()
+
+ def init_poolmanager(self, connections, maxsize, block=False):
+ ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
+ ssl_context.set_ciphers('DEFAULT:@SECLEVEL=1')
+ ssl_context.options |= 1<<2 # OP_LEGACY_SERVER_CONNECT
+
+ if not self.verify:
+ ssl_context.check_hostname = False
+ ssl_context.verify_mode = ssl.CERT_NONE
+
+ if hasattr(ssl_context, "keylog_filename"):
+ sslkeylogfile = environ.get("SSLKEYLOGFILE")
+ if sslkeylogfile:
+ ssl_context.keylog_filename = sslkeylogfile
+
+ self.poolmanager = urllib3.PoolManager(
+ num_pools=connections,
+ maxsize=maxsize,
+ block=block,
+ ssl_context=ssl_context)