Fix hostname/address handling in tunnel proxies#496
Merged
Conversation
Tunnel mode had the two halves of the documented contract inverted. establish_proxy/2 built the CONNECT authority from the :hostname override, so a pinned-IP address was never sent to the proxy and DNS pinning silently stopped working through tunnels. upgrade_connection/3 then used the raw address as the TLS identity, so SNI, certificate verification, and the post-tunnel Host header / HTTP/2 :authority all used the address instead of the declared identity; with an :inet tuple address (documented as supported) the upgrade raised in String.to_charlist/1. Now the CONNECT request targets the connection address (with :inet tuples formatted via :inet.ntoa/1 and IPv6 addresses bracketed) while the TLS upgrade uses the same identity resolution as direct connections. The Host header of the CONNECT request is set to the authority-form target as required by RFC 9112, section 3.2.3; it previously named the proxy. The pkix_test_data/1 helper duplicated in two test modules moved to a shared Mint.TestCertificates support module.
Coverage Report for CI Build 42605087Coverage decreased (-0.009%) to 87.875%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
whatyouhide
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tunnel mode had the documented
address/:hostnamecontract inverted.establish_proxy/2built the CONNECT authority from the:hostnameidentity, so a pinned-IPaddresswas never sent to the proxy and DNS pinning silently stopped working through tunnels.upgrade_connection/3then used the rawaddressas the TLS identity, so SNI, certificate verification, and the post-tunnel Host header / HTTP/2:authorityall used the address instead of the declared identity (and an:inettuple address, which is documented as supported, crashed inString.to_charlist/1).The CONNECT request now targets the connection address (
:inettuples formatted with:inet.ntoa/1, IPv6 bracketed) and the tunnel TLS session uses the same identity resolution as direct connections. The CONNECT request's Host header is now identical to the authority-form target as RFC 9112 (section 3.2.3) requires; it previously named the proxy. Offline regression tests cover the authority, the Host header, tuple addresses, and certificate verification against the:hostnameidentity through the tunnel (5 of the 7 new tests fail on main).Also extracts the
pkix_test_data/1helper that was duplicated across two test modules into a sharedMint.TestCertificatessupport module.