Skip to content

http2: set ServerName for upstream TLS client#761

Open
germanescobar wants to merge 1 commit intoelazarl:masterfrom
germanescobar:codex/h2-servername
Open

http2: set ServerName for upstream TLS client#761
germanescobar wants to merge 1 commit intoelazarl:masterfrom
germanescobar:codex/h2-servername

Conversation

@germanescobar
Copy link
Copy Markdown

@germanescobar germanescobar commented Apr 9, 2026

Hi, we are using goproxy for a sandbox platform that we are building and found this issue that we had to patch in our project, so I asked Codex to help me open this PR:

This fixes an HTTP/2 MITM failure in H2Transport.RoundTrip() when the TLS config used for the upstream client connection does not already include ServerName.

Before this change, the H2 path could fail with:

tls: either ServerName or InsecureSkipVerify must be specified in the tls.Config

The root issue is that RoundTrip() reuses r.TLSConfig as a client TLS config, but that config is often created for the server-side MITM role and may not yet be valid for upstream client verification.

This change:

  • clones the provided TLS config instead of mutating it in place
  • restricts ALPN on the cloned config to h2
  • populates ServerName from the upstream host when it is missing
  • verifies the hostname against that resolved server name

I hit this while testing Git smart-HTTP over HTTPS with downstream HTTP/2 enabled through the proxy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant