Closed as not planned
Description
Line 515 in 0fc58c6
This code is causing many Python programs to fail when downloading dependencies.
It is loading all root certs from the Windows certificate store at once, and it fails if it encounters a single malformed certificate instead of ignoring it and not adding it to its own trust store.
Proposed workaround is:
def _load_windows_store_certs(self, storename, purpose):
certs = bytearray()
try:
for cert, encoding, trust in enum_certificates(storename):
try:
self.load_verify_locations(cadata=cert)
except SSLError:
warnings.warn("Bad certificate in Windows certificate store")
else:
# CA certs are never PKCS#7 encoded
if encoding == "x509_asn":
if trust is True or purpose.oid in trust:
certs.extend(cert)
except PermissionError:
warnings.warn("unable to enumerate Windows certificate store")
return certs
It is very likely this is not enough to fix it properly so if anyone has a better idea on how to solve this issue please advise.
Before you do, I'd like you to have in mind the following things:
- The current error message (stacktrace) shown by Python doesn't help the end user understand the error, much less find the offending certificate
- Even if it did, regular users trying to run a Python application may not have local admin rights to remove those certificates from the OS root CA store
- Even if they had local admin rights, randomly removing root CA certificates trying to figure out which one is responsible can render their operating system unusable
- Even if they had the required knowledge of which CAs they can safely remove, they might need those offending certificates anyway and removing them would just break some other application or intranet website they are using
- In 99% of cases those certificates are not needed for HTTPS communication and can be safely skipped