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
Add timezone-aware API variants for x509 #9661
Add timezone-aware API variants for x509 #9661
Conversation
1be74e6
to
be8e068
Compare
be8e068
to
ba08d96
Compare
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.
Please add documentation and a changelog entry. Code LGTM.
565d90f
to
5f8ae80
Compare
@alex Done! |
@@ -376,6 +376,18 @@ X.509 Certificate Object | |||
>>> cert.not_valid_before | |||
datetime.datetime(2010, 1, 1, 8, 30) | |||
|
|||
.. attribute:: not_valid_before_utc | |||
|
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.
These new attributes need .. versionadded:: 42.0.0
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.
Fixed!
5f8ae80
to
0db9022
Compare
This PRs adds timezone-aware variants for the following properties:
x509.Certificate.not_valid_before
andx509.Certificate.not_valid_after
x509.RevokedCertificate.revocation_date
x509.CertificateRevocationList.last_update
andx509.CertificateRevocationList.next_update
The variants have the same name with
_utc
appended (i.e:not_valid_before
->not_valid_before_utc
).These variants return a
datetime.datetime
object with the timezone set to UTC. Sincecryptography
already internally converted these datetimes to UTC, we only need to return the same object with the timezone set.This is part of #9186: providing the timezone-aware variants is the step before deprecating the naive APIs.