Skip to content

Fix ECH rejection to verify the outer cert against the public_name#407

Open
bindreams wants to merge 3 commits into
refraction-networking:masterfrom
bindreams:fix/ech-rejection-verify-public-name
Open

Fix ECH rejection to verify the outer cert against the public_name#407
bindreams wants to merge 3 commits into
refraction-networking:masterfrom
bindreams:fix/ech-rejection-verify-public-name

Conversation

@bindreams

Copy link
Copy Markdown

On an ECH rejection, verifyServerCertificate incorrectly verifies the presented outer certificate against the inner name (c.config.ServerName), instead of the ClientHelloOuter's public_name (c.serverName). These two names almost always differ, and in that case the verification fails and the handshake aborts with a CertificateVerificationError before the *ECHRejectionError carrying retry_configs is ever surfaced.

As a consequence of this bug, ECH retry recovery can never complete against a real rejecting server. The client always errors out verifying the outer cert against the inner name, so a caller cannot both send ECH and recover from an ECH-config rotation (e.g. Cloudflare's ~hourly key rotation).

This PR fixes the bug by correctly verifying against c.serverName instead of c.config.ServerName.

See also: https://github.com/golang/go/blob/go1.26.1/src/crypto/tls/handshake_client.go#L1118-L1146

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