Skip to content

Commit

Permalink
refactor: expiresAt -> notAfter
Browse files Browse the repository at this point in the history
  • Loading branch information
anfragment committed Dec 15, 2023
1 parent aed5900 commit 4ba7238
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions certmanager/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ func (cm *CertManager) GetCertificate(host string) (*tls.Certificate, error) {
return nil, fmt.Errorf("generate serial number: %v", err)
}

expiresAt := time.Now().Add(certTTL)
notAfter := time.Now().Add(certTTL)
template := x509.Certificate{
SerialNumber: serialNumber,
Subject: pkix.Name{
Organization: []string{"Zen"},
},
DNSNames: []string{host},
NotBefore: time.Now(),
NotAfter: expiresAt,
NotAfter: notAfter,

KeyUsage: x509.KeyUsageDigitalSignature,
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth},
Expand Down Expand Up @@ -71,7 +71,7 @@ func (cm *CertManager) GetCertificate(host string) (*tls.Certificate, error) {
return nil, fmt.Errorf("load key pair: %v", err)
}

cm.certCache.Put(host, expiresAt.Add(-5*time.Minute), &cert) // 5 minute buffer in case a TLS handshake takes a while, the system clock is off, etc.
cm.certCache.Put(host, notAfter.Add(-5*time.Minute), &cert) // 5 minute buffer in case a TLS handshake takes a while, the system clock is off, etc.

return &cert, nil
}

0 comments on commit 4ba7238

Please sign in to comment.