From b5c1ef11c1a57e324920d59d5f5134bfe51e9943 Mon Sep 17 00:00:00 2001 From: pmoulton Date: Fri, 21 Jan 2022 20:22:01 +0900 Subject: [PATCH] Pass length of hostname.encode() to X509_VERIFY_PARAM_set1_host (#5083) * Pass length of hostname.encode() to X509_VERIFY_PARAM_set1_host Passing zero for the size_t length argument of X509_VERIFY_PARAM_set1_host causes MITM Proxy to crash when used with BoringSSL. https://www.openssl.org/docs/man1.1.1/man3/X509_VERIFY_PARAM_set1_host.html https://boringssl.googlesource.com/boringssl/ * Update CHANGELOG.md Co-authored-by: Maximilian Hils --- CHANGELOG.md | 1 + mitmproxy/net/tls.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 666cd7d33..20049b0ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ * Correct documentation example for User-Agent header modification (#4997, @jamesyale) * Fix random connection stalls (#5040, @EndUser509) * Add `n` new flow keybind to mitmweb (#5061, @ianklatzco) +* Fix compatibility with BoringSSL (@pmoulton) ## 28 September 2021: mitmproxy 7.0.4 diff --git a/mitmproxy/net/tls.py b/mitmproxy/net/tls.py index 3e9f53bf0..11a1be4d5 100644 --- a/mitmproxy/net/tls.py +++ b/mitmproxy/net/tls.py @@ -157,7 +157,7 @@ def create_proxy_server_context( ip: bytes = ipaddress.ip_address(hostname).packed except ValueError: SSL._openssl_assert( # type: ignore - SSL._lib.X509_VERIFY_PARAM_set1_host(param, hostname.encode(), 0) == 1 # type: ignore + SSL._lib.X509_VERIFY_PARAM_set1_host(param, hostname.encode(), len(hostname.encode())) == 1 # type: ignore ) else: SSL._openssl_assert( # type: ignore