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

Add timezone-aware API variants for x509 #9661

Merged
merged 2 commits into from Sep 28, 2023

Conversation

facutuesca
Copy link
Contributor

This PRs adds timezone-aware variants for the following properties:

  • x509.Certificate.not_valid_before and x509.Certificate.not_valid_after
  • x509.RevokedCertificate.revocation_date
  • x509.CertificateRevocationList.last_update and x509.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. Since cryptography 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.

Copy link
Member

@alex alex left a 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.

@facutuesca
Copy link
Contributor Author

Please add documentation and a changelog entry. Code LGTM.

@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

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@reaperhulk reaperhulk merged commit ce94de0 into pyca:main Sep 28, 2023
59 checks passed
@facutuesca facutuesca deleted the timezone-aware-x509-apis branch September 28, 2023 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants