-
Notifications
You must be signed in to change notification settings - Fork 580
HDDS-13781. Certificate expiry date should consider time zone daylight saving impact #9209
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
Conversation
adoroszlai
left a comment
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.
Thanks @ChenSammi for the patch. LGTM, have some suggestion to simplify the logic a bit.
| } | ||
|
|
||
| private LocalDateTime expiryFor(LocalDateTime beginDate, NodeType role) { | ||
| private Duration getDuration(LocalDateTime beginDate, NodeType role) { |
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.
nit: beginDate is no longer used, can be removed.
| LocalDateTime beginDate, Duration duration, PKCS10CertificationRequest csr, NodeType role, String certSerialId | ||
| ) throws IOException, OperatorCreationException, CertificateException { | ||
|
|
||
| ZoneId zoneId = ZoneId.systemDefault(); | ||
| ZonedDateTime endDate = beginDate.atZone(zoneId).plus(duration); |
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.
Since beginDate is no longer needed in the signAndStoreCertificate's caller, and it's always now(), we can simplify.
| LocalDateTime beginDate, Duration duration, PKCS10CertificationRequest csr, NodeType role, String certSerialId | |
| ) throws IOException, OperatorCreationException, CertificateException { | |
| ZoneId zoneId = ZoneId.systemDefault(); | |
| ZonedDateTime endDate = beginDate.atZone(zoneId).plus(duration); | |
| Duration duration, PKCS10CertificationRequest csr, NodeType role, String certSerialId | |
| ) throws IOException, OperatorCreationException, CertificateException { | |
| ZonedDateTime beginDate = ZonedDateTime.now(); | |
| ZonedDateTime endDate = beginDate.plus(duration); |
| xcert = approver.sign(config, | ||
| getPrivateKey(), | ||
| getCACertificate(), | ||
| Date.from(beginDate.atZone(ZoneId.systemDefault()).toInstant()), |
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.
| Date.from(beginDate.atZone(ZoneId.systemDefault()).toInstant()), | |
| Date.from(beginDate.toInstant()), |
| LocalDateTime beginDate = LocalDateTime.now(); | ||
| LocalDateTime endDate = | ||
| beginDate.plus(securityConfig.getMaxCertificateDuration()); | ||
| ZoneId zoneId = ZoneId.systemDefault(); | ||
| ZonedDateTime endDate = beginDate.atZone(zoneId).plus(securityConfig.getMaxCertificateDuration()); |
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.
Similarly, here:
ZonedDateTime beginDate = ZonedDateTime.now();
ZonedDateTime endDate = beginDate.plus(securityConfig.getMaxCertificateDuration());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.
Thanks @ChenSammi for updating the patch. It seems this comment was missed.
(Note: LocalDateTime and ZoneId imports will be unused after this change.)
| .setSubject(this.subject) | ||
| .setScmID(this.scmID) | ||
| .setClusterID(this.clusterID) | ||
| .setBeginDate(beginDate) |
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.
| .setBeginDate(beginDate) | |
| .setBeginDate(beginDate.toLocalDateTime()) |
|
@adoroszlai , thanks for the review. |
| import java.time.LocalDateTime; | ||
| import java.time.ZoneId; |
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.
| import java.time.LocalDateTime; | |
| import java.time.ZoneId; |
| ZoneId zoneId = ZoneId.systemDefault(); | ||
| ZonedDateTime endDate = beginDate.atZone(zoneId).plus(securityConfig.getMaxCertificateDuration()); |
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.
| ZoneId zoneId = ZoneId.systemDefault(); | |
| ZonedDateTime endDate = beginDate.atZone(zoneId).plus(securityConfig.getMaxCertificateDuration()); | |
| ZonedDateTime endDate = beginDate.plus(securityConfig.getMaxCertificateDuration()); |
| SecurityConfig securityConfig, KeyPair key) | ||
| throws IOException, SCMSecurityException { | ||
| Preconditions.checkNotNull(this.config); | ||
| LocalDateTime beginDate = LocalDateTime.now(); |
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.
| LocalDateTime beginDate = LocalDateTime.now(); | |
| ZonedDateTime beginDate = ZonedDateTime.now(); |
adoroszlai
left a comment
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.
Thanks @ChenSammi for updating the patch to use ZonedDateTime.
What changes were proposed in this pull request?
The current way of specify endDate( https://github.com/apache/ozone/blob/master/hadoop-hdds/framework/src/main/java/or[…]p/hdds/security/x509/certificate/authority/DefaultCAServer.java) works well on time zone which doesn’t have Daylight Saving, but it will cause the endDate one hour ahead or after the expected time, if the beginDate and endDate, one with Daylight Saving, while another without.
Refer to https://issues.apache.org/jira/browse/HDDS-13781 for more info.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-13781
How was this patch tested?
new unit tests