Skip to content

Commit 2770866

Browse files
fixup! fixup! fixup! NO-SNOW: Add more tests for async crl
1 parent 082932c commit 2770866

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/snowflake/connector/ssl_wrap_socket.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import certifi
2222
import OpenSSL.SSL
23+
from cryptography.utils import CryptographyDeprecationWarning
2324

2425
from .constants import OCSPMode
2526
from .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)

0 commit comments

Comments
 (0)