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

Use timezone-aware timestamps on x509.Certificate if possible #399

Merged

Conversation

priitlatt
Copy link
Contributor

@priitlatt priitlatt commented Apr 17, 2024

Cryptography issues a deprecation warning when timezone-unaware datetime properties are accessed on x509.Certificate instances. For example:

/Users/builder/.pyenv/versions/3.8.13/lib/python3.8/site-packages/codemagic/models/certificate.py:123: CryptographyDeprecationWarning: Properties that return a naïve datetime object have been deprecated. Please switch to not_valid_after_utc.
  return self.certificate.not_valid_after.replace(tzinfo=timezone.utc)

Since version 42.0.0 there are timezone-aware alternatives that should be used instead. In this PR usages of naive datetime properties x509.Certificate.not_valid_after and x509.Certificate.not_valid_before are replaced with timezone-aware properties x509.Certificate.not_valid_after_utc and x509.Certificate.not_valid_before_utc respectively.

@priitlatt priitlatt marked this pull request as ready for review April 17, 2024 08:47
@priitlatt priitlatt merged commit 5b32128 into master Apr 17, 2024
11 checks passed
@priitlatt priitlatt deleted the improvement/do-not-use-deprecated-cryptography-properties branch April 17, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants