[Python-checkins] cpython (merge 3.5 -> default): Issue #27114: Fix SSLContext._load_windows_store_certs fails with

steve.dower python-checkins at python.org
Thu May 26 15:20:13 EDT 2016


https://hg.python.org/cpython/rev/eaee5aed6fbc
changeset:   101511:eaee5aed6fbc
parent:      101508:20d515982b43
parent:      101510:29f163db229e
user:        Steve Dower <steve.dower at microsoft.com>
date:        Thu May 26 12:19:42 2016 -0700
summary:
  Issue #27114: Fix SSLContext._load_windows_store_certs fails with PermissionError

files:
  Lib/ssl.py |  14 +++++++++-----
  Misc/NEWS  |   3 +++
  2 files changed, 12 insertions(+), 5 deletions(-)


diff --git a/Lib/ssl.py b/Lib/ssl.py
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -145,6 +145,7 @@
 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 @@
 
     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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -22,6 +22,9 @@
 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.
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list