Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make certs valid starting yesterday #1653

Merged
merged 1 commit into from
Jul 8, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions security/x509.go
Original file line number Diff line number Diff line change
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