Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

How to control ssl context in a HTTP20Adapter #417

Open
VeNoMouS opened this issue Jul 28, 2019 · 1 comment
Open

How to control ssl context in a HTTP20Adapter #417

VeNoMouS opened this issue Jul 28, 2019 · 1 comment

Comments

@VeNoMouS
Copy link

VeNoMouS commented Jul 28, 2019

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...

@VeNoMouS
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant