hyper
hyper copied to clipboard
How to control ssl context in a HTTP20Adapter
class CipherSuiteAdapter(HTTP20Adapter):
def __init__(self, cipherSuite=None, **kwargs):
self.ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS)
self.ssl_context.set_ciphers(cipherSuite)
pprint(self.ssl_context.get_ciphers())
self.ssl_context.options |= (ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 | ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1)
super(CipherSuiteAdapter, self).__init__(**kwargs)
# ------------------------------------------------------------------------------- #
def init_poolmanager(self, *args, **kwargs):
kwargs['ssl_context'] = self.ssl_context
return super(CipherSuiteAdapter, self).init_poolmanager(*args, **kwargs)
# ------------------------------------------------------------------------------- #
def proxy_manager_for(self, *args, **kwargs):
kwargs['ssl_context'] = self.ssl_context
return super(CipherSuiteAdapter, self).proxy_manager_for(*args, **kwargs)
# ------------------------------------------------------------------------------- #
because calling self.ssl_context.get_ciphers() is not the same what is being provided to the remote server...
Looking at the https://github.com/python-hyper/hyper/blob/development/hyper/contrib.py#L36 , its not possible ... not without changing some things and doing a PR