mirror of
https://github.com/caddyserver/caddy.git
synced 2025-12-08 06:09:53 +00:00
caddytls: ECH key rotation
This commit is contained in:
parent
4bfc3b95b5
commit
57d6671ac6
3 changed files with 219 additions and 69 deletions
|
|
@ -168,21 +168,11 @@ func (cp ConnectionPolicies) TLSConfig(ctx caddy.Context) *tls.Config {
|
|||
tlsApp.RegisterServerNames(echNames)
|
||||
}
|
||||
|
||||
// TODO: Ideally, ECH keys should be rotated. However, as of Go 1.24, the std lib implementation
|
||||
// does not support safely modifying the tls.Config's EncryptedClientHelloKeys field.
|
||||
// So, we implement static ECH keys temporarily. See https://github.com/golang/go/issues/71920.
|
||||
// Revisit this after Go 1.25 is released and implement key rotation.
|
||||
var stdECHKeys []tls.EncryptedClientHelloKey
|
||||
for _, echConfigs := range tlsApp.EncryptedClientHello.configs {
|
||||
for _, c := range echConfigs {
|
||||
stdECHKeys = append(stdECHKeys, tls.EncryptedClientHelloKey{
|
||||
Config: c.configBin,
|
||||
PrivateKey: c.privKeyBin,
|
||||
SendAsRetry: c.sendAsRetry,
|
||||
})
|
||||
}
|
||||
tlsCfg.GetEncryptedClientHelloKeys = func(chi *tls.ClientHelloInfo) ([]tls.EncryptedClientHelloKey, error) {
|
||||
tlsApp.EncryptedClientHello.configsMu.RLock()
|
||||
defer tlsApp.EncryptedClientHello.configsMu.RUnlock()
|
||||
return tlsApp.EncryptedClientHello.stdlibReady, nil
|
||||
}
|
||||
tlsCfg.EncryptedClientHelloKeys = stdECHKeys
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue