File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 2020
2121import certifi
2222import OpenSSL .SSL
23+ from cryptography .utils import CryptographyDeprecationWarning
2324
2425from .constants import OCSPMode
2526from .crl import CertRevocationCheckMode , CRLConfig , CRLValidator
@@ -158,7 +159,16 @@ def load_trusted_certificates(cafile: str | None) -> list[x509.Certificate]:
158159 from cryptography .hazmat .backends import default_backend
159160 from cryptography .x509 import load_der_x509_certificate
160161
161- return [load_der_x509_certificate (cert , default_backend ()) for cert in certs ]
162+ x509_certs = []
163+ for cert in certs :
164+ try :
165+ x509_certs .append (load_der_x509_certificate (cert , default_backend ()))
166+ except CryptographyDeprecationWarning :
167+ # Reason: Parsed a serial number which wasn't positive (i.e., it was negative or zero), which is
168+ # disallowed by RFC 5280. Loading this certificate will cause an exception in a future
169+ # release of cryptography.
170+ continue
171+ return x509_certs
162172
163173
164174@wraps (ssl_ .ssl_wrap_socket )
You can’t perform that action at this time.
0 commit comments