mirror of
https://github.com/mitmproxy/mitmproxy.git
synced 2024-11-27 07:10:51 +00:00
fix cryptography DeprecationWarning (#6790)
* fix cryptography DeprecationWarning * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
1b44691d33
commit
11a086805c
@ -33,6 +33,9 @@
|
||||
([#6767](https://github.com/mitmproxy/mitmproxy/pull/6767), @txrp0x9)
|
||||
* The "save body" feature now also includes WebSocket messages.
|
||||
([#6767](https://github.com/mitmproxy/mitmproxy/pull/6767), @txrp0x9)
|
||||
* Fix compatibility with older cryptography versions and silence a DeprecationWarning on Python <3.11.
|
||||
([#6790](https://github.com/mitmproxy/mitmproxy/pull/6790), @mhils)
|
||||
|
||||
|
||||
## 07 March 2024: mitmproxy 10.2.4
|
||||
|
||||
|
@ -100,16 +100,23 @@ class Cert(serializable.Serializable):
|
||||
|
||||
@property
|
||||
def notbefore(self) -> datetime.datetime:
|
||||
# type definitions haven't caught up with new API yet.
|
||||
return self._cert.not_valid_before_utc # type: ignore
|
||||
try:
|
||||
# type definitions haven't caught up with new API yet.
|
||||
return self._cert.not_valid_before_utc # type: ignore
|
||||
except AttributeError: # pragma: no cover
|
||||
# cryptography < 42.0
|
||||
return self._cert.not_valid_before.replace(tzinfo=datetime.timezone.utc)
|
||||
|
||||
@property
|
||||
def notafter(self) -> datetime.datetime:
|
||||
return self._cert.not_valid_after_utc # type: ignore
|
||||
try:
|
||||
return self._cert.not_valid_after_utc # type: ignore
|
||||
except AttributeError: # pragma: no cover
|
||||
return self._cert.not_valid_after.replace(tzinfo=datetime.timezone.utc)
|
||||
|
||||
def has_expired(self) -> bool:
|
||||
if sys.version_info < (3, 11): # pragma: no cover
|
||||
return datetime.datetime.utcnow() > self._cert.not_valid_after
|
||||
return datetime.datetime.now(datetime.timezone.utc) > self.notafter
|
||||
return datetime.datetime.now(datetime.UTC) > self.notafter
|
||||
|
||||
@property
|
||||
|
Loading…
Reference in New Issue
Block a user