Use `_utc` APIs from cryptography, fix #6717 (#6718)

This commit is contained in:
Maximilian Hils 2024-03-07 17:00:51 +01:00 committed by GitHub
parent b4f49d0186
commit 9acf06427a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 7 deletions

View File

@ -7,6 +7,9 @@
## Unreleased: mitmproxy next
* Use newer cryptography APIs to avoid CryptographyDeprecationWarnings.
This bumps the minimum required version to cryptography 42.0.
([#6718](https://github.com/mitmproxy/mitmproxy/pull/6718), @mhils)
## 06 March 2024: mitmproxy 10.2.3

View File

@ -100,15 +100,12 @@ class Cert(serializable.Serializable):
@property
def notbefore(self) -> datetime.datetime:
# TODO: Use self._cert.not_valid_before_utc once cryptography 42 hits.
# x509.Certificate.not_valid_before is a naive datetime in UTC
return self._cert.not_valid_before.replace(tzinfo=datetime.timezone.utc)
# type definitions haven't caught up with new API yet.
return self._cert.not_valid_before_utc # type: ignore
@property
def notafter(self) -> datetime.datetime:
# TODO: Use self._cert.not_valid_after_utc once cryptography 42 hits.
# x509.Certificate.not_valid_after is a naive datetime in UTC
return self._cert.not_valid_after.replace(tzinfo=datetime.timezone.utc)
return self._cert.not_valid_after_utc # type: ignore
def has_expired(self) -> bool:
if sys.version_info < (3, 11): # pragma: no cover

View File

@ -35,7 +35,7 @@ dependencies = [
"asgiref>=3.2.10,<3.8",
"Brotli>=1.0,<1.2",
"certifi>=2019.9.11", # no semver here - this should always be on the last release!
"cryptography>=39.0,<42.1",
"cryptography>=42.0,<42.1",
"flask>=1.1.1,<3.1",
"h11>=0.11,<0.15",
"h2>=4.1,<5",