diff options
author | Maximilian Hils <git@maximilianhils.com> | 2019-11-11 18:35:06 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2019-11-11 18:35:06 +0100 |
commit | f97996126f7a7606f8601f0318f0a70a4e818c6c (patch) | |
tree | 693148a4e729893c9e4f6245d191d7b14a576690 /mitmproxy/net | |
parent | 3af4647804700bb6e86a9e1b73d7bf8612d872fa (diff) | |
download | mitmproxy-f97996126f7a7606f8601f0318f0a70a4e818c6c.tar.gz mitmproxy-f97996126f7a7606f8601f0318f0a70a4e818c6c.tar.bz2 mitmproxy-f97996126f7a7606f8601f0318f0a70a4e818c6c.zip |
minor improvements and sans-io adjustments
Diffstat (limited to 'mitmproxy/net')
-rw-r--r-- | mitmproxy/net/tls.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/mitmproxy/net/tls.py b/mitmproxy/net/tls.py index 4dc61969..48392d1b 100644 --- a/mitmproxy/net/tls.py +++ b/mitmproxy/net/tls.py @@ -295,6 +295,17 @@ def create_client_context( return context +def accept_all( + conn_: SSL.Connection, + x509: SSL.X509, + errno: int, + err_depth: int, + is_cert_verified: bool, +) -> bool: + # Return true to prevent cert verification error + return True + + def create_server_context( cert: typing.Union[certs.Cert, str], key: SSL.PKey, @@ -324,16 +335,6 @@ def create_server_context( until then we're conservative. """ - def accept_all( - conn_: SSL.Connection, - x509: SSL.X509, - errno: int, - err_depth: int, - is_cert_verified: bool, - ) -> bool: - # Return true to prevent cert verification error - return True - if request_client_cert: verify = SSL.VERIFY_PEER else: @@ -425,7 +426,7 @@ class ClientHello: return self._client_hello.cipher_suites.cipher_suites @property - def sni(self): + def sni(self) -> typing.Optional[bytes]: if self._client_hello.extensions: for extension in self._client_hello.extensions.extensions: is_valid_sni_extension = ( @@ -435,7 +436,7 @@ class ClientHello: check.is_valid_host(extension.body.server_names[0].host_name) ) if is_valid_sni_extension: - return extension.body.server_names[0].host_name.decode("idna") + return extension.body.server_names[0].host_name return None @property @@ -478,5 +479,4 @@ class ClientHello: ) def __repr__(self): - return "ClientHello(sni: %s, alpn_protocols: %s, cipher_suites: %s)" % \ - (self.sni, self.alpn_protocols, self.cipher_suites) + return f"ClientHello(sni: {self.sni}, alpn_protocols: {self.alpn_protocols})" |