Skip to content

Commit

Permalink
Reraise original error on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmlarson committed Apr 24, 2024
1 parent 52f0893 commit 373776a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/truststore/_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def _verify_peercerts_impl(
server_hostname,
chain_flags=chain_flags,
)
except ssl.SSLCertVerificationError:
except ssl.SSLCertVerificationError as e:
# If that fails but custom CA certs have been added
# to the SSLContext using load_verify_locations,
# try verifying using a custom chain engine
Expand All @@ -384,15 +384,19 @@ def _verify_peercerts_impl(
binary_form=True
)
if custom_ca_certs:
_verify_using_custom_ca_certs(
ssl_context,
custom_ca_certs,
hIntermediateCertStore,
pCertContext,
pChainPara,
server_hostname,
chain_flags=chain_flags,
)
try:
_verify_using_custom_ca_certs(
ssl_context,
custom_ca_certs,
hIntermediateCertStore,
pCertContext,
pChainPara,
server_hostname,
chain_flags=chain_flags,
)
# Raise the original error, not the new error.
except ssl.SSLCertVerificationError:
raise e from None
else:
raise
finally:
Expand Down

0 comments on commit 373776a

Please sign in to comment.