diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-09-02 10:53:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-02 10:53:59 (GMT) |
commit | 8c01b3426860acd5252a644e222b1d0d1f4e118f (patch) | |
tree | 3f8ef3eaf250616422c12f15186b846a3c590355 /Lib/ssl.py | |
parent | 8a4f7082207cf11b26818c3290097856737b0385 (diff) | |
download | cpython-8c01b3426860acd5252a644e222b1d0d1f4e118f.zip cpython-8c01b3426860acd5252a644e222b1d0d1f4e118f.tar.gz cpython-8c01b3426860acd5252a644e222b1d0d1f4e118f.tar.bz2 |
[3.13] gh-79846: Make ssl.create_default_context() ignore invalid certificates (GH-91740) (#122768)
gh-79846: Make ssl.create_default_context() ignore invalid certificates (GH-91740)
An error in one certificate should not cause the whole thing to fail.
(cherry picked from commit 9e551f9b351440ebae79e07a02d0e4a1b61d139e)
Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/ssl.py')
-rw-r--r-- | Lib/ssl.py | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -513,18 +513,17 @@ class SSLContext(_SSLContext): self._set_alpn_protocols(protos) def _load_windows_store_certs(self, storename, purpose): - certs = bytearray() try: for cert, encoding, trust in enum_certificates(storename): # CA certs are never PKCS#7 encoded if encoding == "x509_asn": if trust is True or purpose.oid in trust: - certs.extend(cert) + try: + self.load_verify_locations(cadata=cert) + except SSLError as exc: + warnings.warn(f"Bad certificate in Windows certificate store: {exc!s}") except PermissionError: warnings.warn("unable to enumerate Windows certificate store") - if certs: - self.load_verify_locations(cadata=certs) - return certs def load_default_certs(self, purpose=Purpose.SERVER_AUTH): if not isinstance(purpose, _ASN1Object): |