codemagic-ci-cd / cli-tools

Various utilities to managing Android and iOS app builds, code signing, and deployment.
https://codemagic.io/start/
GNU General Public License v3.0
235 stars 39 forks source link

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

Closed priitlatt closed 3 months ago

priitlatt commented 3 months ago

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.