]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #27114: Fix SSLContext._load_windows_store_certs fails with PermissionError
authorSteve Dower <steve.dower@microsoft.com>
Thu, 26 May 2016 19:18:12 +0000 (12:18 -0700)
committerSteve Dower <steve.dower@microsoft.com>
Thu, 26 May 2016 19:18:12 +0000 (12:18 -0700)
Lib/ssl.py
Misc/NEWS

index 65ad38f899ed4660fe21c20dc9ce6091803e5301..3f5c3c4d07aab37f450e45488e7db4eadd467927 100644 (file)
@@ -145,6 +145,7 @@ from socket import socket, AF_INET, SOCK_STREAM, create_connection
 from socket import SOL_SOCKET, SO_TYPE
 import base64        # for DER-to-PEM translation
 import errno
+import warnings
 
 
 socket_error = OSError  # keep that public name in module namespace
@@ -405,11 +406,14 @@ class SSLContext(_SSLContext):
 
     def _load_windows_store_certs(self, storename, purpose):
         certs = bytearray()
-        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:
+            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)
+        except PermissionError:
+            warnings.warn("unable to enumerate Windows certificate store")
         if certs:
             self.load_verify_locations(cadata=certs)
         return certs
index 4918265b660908176a1da7783fb9317b0bdd3291..b3795fd94342c23c96c9e1d14d325eb7624f9093 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -126,6 +126,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #27114: Fix SSLContext._load_windows_store_certs fails with
+  PermissionError
+
 - Issue #18383: Avoid creating duplicate filters when using filterwarnings
   and simplefilter.  Based on patch by Alex Shkop.