Skip to content

Commit 7d873fe

Browse files
authored
Ceremony: add checks for too-large validity period (#8446)
We commit to these values in our CP/CPS, we should enforce them in code as well.
1 parent c1af7fc commit 7d873fe

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

cmd/ceremony/cert.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,23 @@ func makeTemplate(randReader io.Reader, profile *certProfile, pubKey []byte, tbc
252252
if err != nil {
253253
return nil, err
254254
}
255-
cert.NotBefore = notBefore
256255
notAfter, err := time.Parse(time.DateTime, profile.NotAfter)
257256
if err != nil {
258257
return nil, err
259258
}
259+
validity := notAfter.Add(time.Second).Sub(notBefore)
260+
if ct == rootCert && validity >= 9132*24*time.Hour {
261+
// The value 9132 comes directly from the BRs, where it is described
262+
// as "approximately 25 years". It's equal to 365 * 25 + 7, to allow
263+
// for some leap years.
264+
return nil, fmt.Errorf("root cert validity too large: %s >= 25 years", validity)
265+
} else if (ct == intermediateCert || ct == crossCert) && validity >= 8*365*24*time.Hour {
266+
// Our CP/CPS states "at most 8 years", so we calculate that number
267+
// in the most conservative way (i.e. not accounting for leap years)
268+
// to give ourselves a buffer.
269+
return nil, fmt.Errorf("subordinate CA cert validity too large: %s >= 8 years", validity)
270+
}
271+
cert.NotBefore = notBefore
260272
cert.NotAfter = notAfter
261273
}
262274

test/certs/intermediate-cert-ceremony-ecdsa-cross.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ certificate-profile:
1515
common-name: {{ .CommonName }}
1616
organization: good guys
1717
country: US
18-
not-before: 2020-01-01 12:00:00
19-
not-after: 2040-01-01 12:00:00
18+
not-before: 2025-07-01 00:00:00
19+
not-after: 2030-06-30 23:59:59
2020
crl-url: http://rsa.example.com/crl
2121
issuer-url: http://rsa.example.com/cert
2222
policies:

test/certs/intermediate-cert-ceremony-ecdsa.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ certificate-profile:
1414
common-name: {{ .CommonName }}
1515
organization: good guys
1616
country: US
17-
not-before: 2020-01-01 12:00:00
18-
not-after: 2040-01-01 12:00:00
17+
not-before: 2025-07-01 00:00:00
18+
not-after: 2030-06-30 23:59:59
1919
crl-url: http://ecdsa.example.com/crl
2020
issuer-url: http://ecdsa.example.com/cert
2121
policies:

test/certs/intermediate-cert-ceremony-rsa.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ certificate-profile:
1414
common-name: {{ .CommonName }}
1515
organization: good guys
1616
country: US
17-
not-before: 2020-01-01 12:00:00
18-
not-after: 2040-01-01 12:00:00
17+
not-before: 2025-07-01 00:00:00
18+
not-after: 2030-06-30 23:59:59
1919
crl-url: http://rsa.example.com/crl
2020
issuer-url: http://rsa.example.com/cert
2121
policies:

0 commit comments

Comments
 (0)