Skip to content

Commit 29936c9

Browse files
committed
兼容高版本cryptography库
1 parent 1156b4c commit 29936c9

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

docs/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [1.2.45] - 2024-02-25
4+
5+
### Fixed
6+
7+
- 兼容高版本cryptography库
8+
39
## [1.2.44] - 2024-02-05
410

511
### Fixed

docs/qq.png

209 KB
Loading

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name="wechatpayv3",
9-
version="1.2.44",
9+
version="1.2.45",
1010
author="minibear",
1111
description="微信支付 API v3 Python SDK(python sdk for wechatpay v3)",
1212
long_description=long_description,

wechatpayv3/core.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ def _update_certificates(self):
5353
certificate = load_certificate(cert_str)
5454
if not certificate:
5555
continue
56-
now = datetime.now(timezone.utc)
57-
if now < certificate.not_valid_before_utc or now > certificate.not_valid_after_utc:
58-
continue
56+
if (int(cryptography_version.split(".")[0]) < 42):
57+
now = datetime.utcnow()
58+
if now < certificate.not_valid_before or now > certificate.not_valid_after:
59+
continue
60+
else:
61+
now = datetime.now(timezone.utc)
62+
if now < certificate.not_valid_before_utc or now > certificate.not_valid_after_utc:
63+
continue
5964
self._certificates.append(certificate)
6065
if not self._cert_dir:
6166
continue

0 commit comments

Comments
 (0)