Skip to content

Commit

Permalink
Make certs valid starting yesterday
Browse files Browse the repository at this point in the history
This lets us continue in the face of clock skew, specifically
on boot2docker: boot2docker/boot2docker#69
  • Loading branch information
marc committed Jul 8, 2015
1 parent 875d758 commit 5078d07
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions security/x509.go
Expand Up @@ -37,6 +37,9 @@ import (
// Most fields and settings are hard-coded. TODO(marc): allow customization.

const (
// Make certs valid a day before to handle clock issues, specifically
// boot2docker: https://github.com/boot2docker/boot2docker/issues/69
validFrom = -time.Hour * 24
validFor = time.Hour * 24 * 365
maxPathLength = 1
caCommonName = "Cockroach CA"
Expand Down Expand Up @@ -83,7 +86,8 @@ func newTemplate(commonName string) (*x509.Certificate, error) {
return nil, err
}

notBefore := time.Now()
notBefore := time.Now().Add(validFrom)
notAfter := notBefore.Add(validFor)

cert := &x509.Certificate{
SerialNumber: serialNumber,
Expand All @@ -92,7 +96,7 @@ func newTemplate(commonName string) (*x509.Certificate, error) {
CommonName: commonName,
},
NotBefore: notBefore,
NotAfter: notBefore.Add(validFor),
NotAfter: notAfter,

KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
}
Expand Down

0 comments on commit 5078d07

Please sign in to comment.