Skip to content

Commit

Permalink
Raise a better exception when peer sends no certificates on Windows (#…
Browse files Browse the repository at this point in the history
…135)

Co-authored-by: David Glick <[email protected]>
  • Loading branch information
sethmlarson and davisagli authored Apr 29, 2024
1 parent f769a07 commit c9c34c0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/truststore/_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,12 @@ def _verify_peercerts_impl(
server_hostname: str | None = None,
) -> None:
"""Verify the cert_chain from the server using Windows APIs."""

# If the peer didn't send any certificates then
# we can't do verification. Raise an error.
if not cert_chain:
raise ssl.SSLCertVerificationError("Peer sent no certificates to verify")

pCertContext = None
hIntermediateCertStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, None, 0, None)
try:
Expand Down

0 comments on commit c9c34c0

Please sign in to comment.