-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: crypto/tls: add GetEncryptedClientHelloKeys callback #71920
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? No Sign in to your account
Comments
cc @FiloSottile @rolandshoemaker @golang/security |
Is the only dynamic configuration (other than the ECH keys) the certificates for the unwrapped SNI? If so can you just offload that logic to a GetCertificate callback (which can be populated in the config returned from GetConfigForClient, if that helps)? |
I did consider that, and it's tempting to do that, but unfortunately, Caddy users can customize much about the TLS connection: https://caddyserver.com/docs/json/apps/http/servers/tls_connection_policies/ I guess in TLS 1.3 (especially with ECH enabled), many of the parameters have no effect or are overridden by hard-coded values to ensure compliance, but parameters like client authentication ( So, yes I think that would be a workaround, but I'd have to disclaim in our docs that enabling ECH essentially ignores all other TLS configuration properties. I guess I'm hoping for a way to still have control over the TLS config for the unwrapped ClientHello when GetConfigForClient is used. That'd be ideal -- but I don't want to try to force a square peg into a round hole. It could be an odd use case maybe. |
When a new (refreshed) TLS ECH key is created, it is desirable that the prior key still be valid for a short period, but the prior key should now have [Edit: so not only is the list of keys dynamic, but it is desirable to be able to change the properties on each key. (Alt: Could remove key and re-add same key but with altered properties)] |
My memory of how I actually implemented the client hello switching paged out of my brain almost immediately after 1.24 was finished, looking back at the actual code I see how this is problematic. We currently switch out the client hello before calling GetConfigForClient, so the returned config only ever applies to the inner hello. I think this makes sense, since the outer config should never really require special config settings, except EncryptedClientHelloKeys. Unfortunately this doesn't leave any way to currently change EncryptedClientHelloKeys safely once the Config is passed to a Conn because we say the Config cannot be mutated. So unless the caller is manually creating configs with I think the only viable option here is to add a new callback, e.g. |
Note, because this will be a new API, it'll need to wait for 1.25. |
FWIW I really like the design choice overall -- it makes generating, publishing, and serving ECH keys elegantly symmetric. The remaining puzzle piece is the on-line rotation. A callback should do the trick. 💯 No particular hurry. I have it working without key rotation for now, as it's mainly a "good to have" feature but not strictly necessary. So Go 1.25 is fine with me. ECH has been interesting in reshaping my view of TLS since, for the first time I think, a TLS connection may be established strictly for the purpose of TLS itself, rather than for application data. (The one case being, a TLS handshake for the purpose of conveying ECH retry-enabled configs. I think. Maybe there's others I haven't known about.) So I had to decide in my application that the outer handshake is abstracted away from the user, since it is not in any way related to or used for application data/use. Given that paradigm, I think limiting the data populated into the outer ClientHelloInfo is acceptable, and worst case scenario, more data can be added later if needed. Although, how would you feel about preserving the underlying Conn? Since some filtering is done based on remote IP, for example. |
Go version
go version go1.24.0 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I'm attempting to implement the ECH spec with regards to key rotation. It states in 10.10.5:
The application (Caddy in this case) requires use of
GetConfigForClient
.What did you see happen?
The problem is,
tls.Config.EncryptedClientHelloKeys
is a static field, not a callback likeGetCertificate
.This means we have to start a new TLS server with the updated ECH keys, which is complex and can be tricky to do without downtime.
I also realized that
GetConfigForClient
is not recursive... at first I tried usingGetConfigForClient
to return a tls.Config populated especially for ECH:But this results in "no certificates configured", because the returned Config's
GetConfigForClient
isn't called, and sure enough it has no certs. Relevant code:https://cs.opensource.google/go/go/+/master:src/crypto/tls/handshake_server.go;l=148-168?q=GetConfigForClient&ss=go%2Fgo&start=11
But we can't return the final tls.Config yet (the one with certificates) because we don't have the inner SNI yet.
What did you expect to see?
I was hoping that GetConfigForClient + EncryptedClientHelloKeys could play well together... in the case of ECH, maybe allow GetConfigForClient to be used to unwrap the outer Hello, and also be used for the inner. (i.e. allow calling it twice, once before once after processing ECH) Or, make a new field,
GetEncryptedClientHelloKeys
callback function, much likeGetCertificate
.Rotating keys is beneficial for security and encouraged by the spec.
Do you have any other suggestions for making this work as-is? Or is this something that can be enhanced?
Thanks again for server-side ECH 💯
The text was updated successfully, but these errors were encountered: