Commit 48df37db authored by Steve Dower's avatar Steve Dower

Issue #27114: Fix SSLContext._load_windows_store_certs fails with PermissionError

parents e67c92ea 33bc4a29
...@@ -145,6 +145,7 @@ from socket import socket, AF_INET, SOCK_STREAM, create_connection ...@@ -145,6 +145,7 @@ from socket import socket, AF_INET, SOCK_STREAM, create_connection
from socket import SOL_SOCKET, SO_TYPE from socket import SOL_SOCKET, SO_TYPE
import base64 # for DER-to-PEM translation import base64 # for DER-to-PEM translation
import errno import errno
import warnings
socket_error = OSError # keep that public name in module namespace socket_error = OSError # keep that public name in module namespace
...@@ -405,11 +406,14 @@ class SSLContext(_SSLContext): ...@@ -405,11 +406,14 @@ class SSLContext(_SSLContext):
def _load_windows_store_certs(self, storename, purpose): def _load_windows_store_certs(self, storename, purpose):
certs = bytearray() certs = bytearray()
try:
for cert, encoding, trust in enum_certificates(storename): for cert, encoding, trust in enum_certificates(storename):
# CA certs are never PKCS#7 encoded # CA certs are never PKCS#7 encoded
if encoding == "x509_asn": if encoding == "x509_asn":
if trust is True or purpose.oid in trust: if trust is True or purpose.oid in trust:
certs.extend(cert) certs.extend(cert)
except PermissionError:
warnings.warn("unable to enumerate Windows certificate store")
if certs: if certs:
self.load_verify_locations(cadata=certs) self.load_verify_locations(cadata=certs)
return certs return certs
......
...@@ -22,6 +22,9 @@ Core and Builtins ...@@ -22,6 +22,9 @@ Core and Builtins
Library Library
------- -------
- Issue #27114: Fix SSLContext._load_windows_store_certs fails with
PermissionError
- Issue #18383: Avoid creating duplicate filters when using filterwarnings - Issue #18383: Avoid creating duplicate filters when using filterwarnings
and simplefilter. Based on patch by Alex Shkop. and simplefilter. Based on patch by Alex Shkop.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment