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 <github@maximilianhils.com>
This commit is contained in:
pmoulton 2022-01-21 20:22:01 +09:00 committed by GitHub
parent 11c22d8a4a
commit b5c1ef11c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

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

View File

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