Skip to content

reverse_proxy with versions 3 silently ignores tls_trust_pool and verifies against the system roots - #8042

Merged
steadytao merged 2 commits into
caddyserver:masterfrom
tippexs:fix/h3-transport-trust-pool
Sep 21, 2026
Merged

steadytao merged 2 commits into
caddyserver:masterfrom
tippexs:fix/h3-transport-trust-pool

Conversation

@tippexs

@tippexs tippexs commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Issue Details

Fixes #8041

A reverse_proxy that speaks HTTP/3 to its upstream ignores the CA configured with tls_trust_pool.

Every dial fails with x509: certificate signed by unknown authority, because the HTTP/3 transport is built with RootCAs == nil and Go falls back to the system trust store. I have populated our Certs to this to make it work for now.

The same proxy without versions 3 honours the trust pool correctly, which makes this look like a certificate problem rather than a config one.

Minimal reproduction:

An upstream serving HTTP/3 with a certificate from a private CA:

site.internal {
      reverse_proxy backend:4001 {
              transport http {
                      tls
                      tls_server_name backend
                      tls_trust_pool file /tls/myRootCa.crt
                      versions 3
              }
      }
}
  • Expected: the upstream's certificate verifies against /tls/myRootCa.crt.
  • Actual: tls: failed to verify certificate: x509: certificate signed by unknown authority. Dropping versions 3 (so the proxy uses HTTP/1.1 or HTTP/2) makes the identical config work.

The running config still shows the pool, which is what makes this hard to spot.

GET /config/ returns:

{"protocol":"http","tls":{"ca":{"pem_files":["/tls/myRootCa.crt"],"provider":"file"},"server_name":"backend"},"versions":["3"]}

Cause (Per my best guess)

HTTPTransport.NewTransport calls MakeTLSClientConfig twice:

// modules/caddyhttp/reverseproxy/httptransport.go:422 for the HTTP/1.1+2 transport
rt.TLSClientConfig, err = h.TLS.MakeTLSClientConfig(caddyCtx)

// modules/caddyhttp/reverseproxy/httptransport.go:507 for the HTTP/3 transport
h.h3Transport.TLSClientConfig, err = h.TLS.MakeTLSClientConfig(caddyCtx)

MakeTLSClientConfig reaches the trust pool through ctx.LoadModule(t, "CARaw") and LoadModuleclears the raw field on its way out.

So on the second call t.CARaw is nil, the cfg.RootCAs = ca.CertPool() branch is skipped, and the HTTP/3 transport gets a config with no roots and falls back.

The cost falls entirely on the HTTP/3 path, because RoundTrip prefers h3Transport whenever it exists (httptransport.go:648). The transport that received the trust pool is never used for requests, the one that serves every request is the one that lost it.

Module-backed fields are the only ones affected: server_name, insecure_skip_verify and theclient-certificate paths are plain struct fields and survive both calls.

Build the client config once and give the HTTP/3 transport a clone, rather than calling MakeTLSClientConfig a second time.

Environment

Reproduced on a build from master (September 2026), Alpine container, Go's system roots without the private CA installed. Both call sites and the LoadModule reset are unchanged in current master.

Assistance Disclosure

Claude to trace down the bug and testing. Implementation as well as the bug report Without AI

@CLAassistant

CLAassistant commented Sep 20, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

…pool

reuse the config built for the HTTP/1.1+2 transport and give the HTTP/3
transport a clone of it to honour the tls_trust_pool

Signed-off-by: Timo Stark <tippexs91@googlemail.com>
Co-authored-by: Faiyaz Rahman <faiyazrahman03@gmail.com>
@tippexs
tippexs force-pushed the fix/h3-transport-trust-pool branch from e62f613 to 99a50b8 Compare September 20, 2026 20:31

@steadytao steadytao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks alright.

@steadytao steadytao added the bug 🐞 Something isn't working label Sep 21, 2026
@steadytao steadytao added this to the v2.11.5 milestone Sep 21, 2026
@tippexs
tippexs requested a review from WeidiDeng September 21, 2026 12:14
@steadytao
steadytao merged commit c18099a into caddyserver:master Sep 21, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reverse_proxy with versions 3 silently ignores tls_trust_pool and verifies against the system roots

4 participants