Skip to content

Commit d2a4d29

Browse files
VERIFY_X509_PARTIAL_CHAIN
1 parent 817bcc8 commit d2a4d29

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/snowflake/connector/connection_diagnostic.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ def __test_socket_get_cert(
240240

241241
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
242242
context.load_verify_locations(certifi.where())
243+
# Best-effort: enable partial-chain when supported
244+
_partial_flag = getattr(ssl, "VERIFY_X509_PARTIAL_CHAIN", 0)
245+
if _partial_flag and hasattr(context, "verify_flags"):
246+
context.verify_flags |= _partial_flag
243247
sock = context.wrap_socket(conn, server_hostname=host)
244248
certificate = ssl.DER_cert_to_PEM_cert(sock.getpeercert(True))
245249
http_request = f"""GET / {host}:{port} HTTP/1.1\r\n

test/unit/test_ssl_partial_chain_handshake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_partial_chain_handshake_succeeds_with_intermediate_as_anchor():
150150
host, port = addr_holder[0]
151151

152152
# Build PyOpenSSL context with only intermediate as trust anchor
153-
ctx = ssw._build_pyopenssl_context_with_ca_and_partial_chain(
153+
ctx = ssw._build_context_with_partial_chain(
154154
None
155155
) # pylint: disable=protected-access
156156
# Load intermediate into store via PEM file path by reusing helper

0 commit comments

Comments
 (0)