Skip to content

Commit c9c34c0

Browse files
Raise a better exception when peer sends no certificates on Windows (#135)
Co-authored-by: David Glick <[email protected]>
1 parent f769a07 commit c9c34c0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/truststore/_windows.py

+6
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,12 @@ def _verify_peercerts_impl(
325325
server_hostname: str | None = None,
326326
) -> None:
327327
"""Verify the cert_chain from the server using Windows APIs."""
328+
329+
# If the peer didn't send any certificates then
330+
# we can't do verification. Raise an error.
331+
if not cert_chain:
332+
raise ssl.SSLCertVerificationError("Peer sent no certificates to verify")
333+
328334
pCertContext = None
329335
hIntermediateCertStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, None, 0, None)
330336
try:

0 commit comments

Comments
 (0)