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
|
|
@ -335,7 +335,6 @@ func (t *TLS) Provision(ctx caddy.Context) error {
|
|||
|
||||
// ECH (Encrypted ClientHello) initialization
|
||||
if t.EncryptedClientHello != nil {
|
||||
t.EncryptedClientHello.configs = make(map[string][]echConfig)
|
||||
outerNames, err := t.EncryptedClientHello.Provision(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("provisioning Encrypted ClientHello components: %v", err)
|
||||
|
|
@ -411,12 +410,27 @@ func (t *TLS) Start() error {
|
|||
return fmt.Errorf("automate: managing %v: %v", t.automateNames, err)
|
||||
}
|
||||
|
||||
// publish ECH configs in the background; does not need to block
|
||||
// server startup, as it could take a while
|
||||
if t.EncryptedClientHello != nil {
|
||||
echLogger := t.logger.Named("ech")
|
||||
|
||||
// publish ECH configs in the background; does not need to block
|
||||
// server startup, as it could take a while
|
||||
go func() {
|
||||
if err := t.publishECHConfigs(); err != nil {
|
||||
t.logger.Named("ech").Error("publication(s) failed", zap.Error(err))
|
||||
echLogger.Error("publication(s) failed", zap.Error(err))
|
||||
}
|
||||
}()
|
||||
|
||||
// keep ECH keys rotated
|
||||
go func() {
|
||||
for range time.Tick(1 * time.Hour) {
|
||||
// ensure old keys are rotated out
|
||||
t.EncryptedClientHello.configsMu.Lock()
|
||||
err = t.EncryptedClientHello.rotateECHKeys(t.ctx, echLogger, false)
|
||||
t.EncryptedClientHello.configsMu.Unlock()
|
||||
if err != nil {
|
||||
echLogger.Error("rotating ECH configs failed", zap.Error(err))
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue