Fix HTTP-01 challenge for IPv6 literal addresses#377
Fix HTTP-01 challenge for IPv6 literal addresses#377mholt merged 1 commit intocaddyserver:masterfrom
Conversation
When the ACME CA sends an HTTP-01 challenge request to an IPv6 address, the Host header is bracketed (e.g. [2001:db8::1]) without a port. net.SplitHostPort fails on this input, causing hostOnly() to return the bracketed form, which doesn't match the bare IP in challenge.Identifier.Value. Strip brackets from bare IPv6 addresses in hostOnly().
2ba2129 to
68acab0
Compare
|
Huh... is that even valid form? I thought |
|
Yes, it's valid form — see RFC 9112 §3.2: It's exactly what Boulder produces. va/http.go wraps IPv6 identifiers in brackets and then constructs Reproducer: req, _ := http.NewRequest("GET", "http://[2001:db8::1]/.well-known/acme-challenge/x", nil)
// req.Host == "[2001:db8::1]"
// wire: "Host: [2001:db8::1]"Downstream this hits |
mholt
left a comment
There was a problem hiding this comment.
Ok. Fair enough I guess, thank you
What changed
Strip square brackets from bare IPv6 literals in
hostOnly()whennet.SplitHostPortreturns an error.Why
For HTTP-01 validation against an IPv6 literal, the CA sends a
Hostheader like[2001:db8::1]without a port.hostOnly()returns that bracketed value, whilechallenge.Identifier.Valueholds the bare IPv6 address, so the host check fails.Validation
go test ./...