Kaynağa Gözat

Fix a couple of race conditions in the renewal of certificates.

Mariano Cano 6 yıl önce
ebeveyn
işleme
3d6a18180e
2 değiştirilmiş dosya ile 3 ekleme ve 1 silme
  1. 1 1
      ca/mutable_tls_config.go
  2. 2 0
      ca/renew.go

+ 1 - 1
ca/mutable_tls_config.go

@@ -40,7 +40,7 @@ func (c *mutableTLSConfig) Init(base *tls.Config) {
 // tls.Config GetConfigForClient.
 func (c *mutableTLSConfig) TLSConfig() (config *tls.Config) {
 	c.RLock()
-	config = c.config
+	config = c.config.Clone()
 	c.RUnlock()
 	return
 }

+ 2 - 0
ca/renew.go

@@ -80,7 +80,9 @@ func NewTLSRenewer(cert *tls.Certificate, fn RenewFunc, opts ...tlsRenewerOption
 func (r *TLSRenewer) Run() {
 	cert := r.getCertificate()
 	next := r.nextRenewDuration(cert.Leaf.NotAfter)
+	r.Lock()
 	r.timer = time.AfterFunc(next, r.renewCertificate)
+	r.Unlock()
 }
 
 // RunContext starts the certificate renewer for the given certificate.