-
Notifications
You must be signed in to change notification settings - Fork 68
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
Pin notAfter dates for certificates to max out at signing CA notAfter date #378
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,11 +93,24 @@ private X509Certificate getSignedByIssuer( | |
|
||
final BigInteger certificateSerialNumber = serialNumberGenerator.generate(); | ||
|
||
Date nvb = Date.from(now); | ||
Data nva = Date.from(now.plus(Duration.ofDays(params.getDuration()))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't compile - should be "Date". Please run "gradlew test" after fixing. |
||
if (issuerCertificate != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add unit test coverage for this new logic? I'm assuming we didn't already have good assertions for it, even though the tests hit this code. |
||
// don't allow a child certificate to be valid before the signing certificate | ||
if (nvb.isBefore(issuerCertificate.getNotBefore())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There isn't an |
||
nvb = issuerCertificate.getNotBefore(); | ||
} | ||
// don't allow a child certificate to be valid after the signing certificate | ||
if (nva.isAfter(issuerCertificate.getNotAfter())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
nva = issuerCertificate.getNotAfter(); | ||
} | ||
} | ||
|
||
final JcaX509v3CertificateBuilder certificateBuilder = new JcaX509v3CertificateBuilder( | ||
issuerDn, | ||
certificateSerialNumber, | ||
Date.from(now), | ||
Date.from(now.plus(Duration.ofDays(params.getDuration()))), | ||
nvb, | ||
nva, | ||
params.getX500Principal(), | ||
keyPair.getPublic() | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest more descriptive names like notBefore and notAfter.