From 33bc4a29832ba2c709847ffe8fb0c7a482733f0c Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Thu, 26 May 2016 12:18:12 -0700 Subject: Issue #27114: Fix SSLContext._load_windows_store_certs fails with PermissionError --- Lib/ssl.py | 14 +++++++++----- Misc/NEWS | 3 +++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Lib/ssl.py b/Lib/ssl.py index 65ad38f..3f5c3c4 100644 --- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -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 diff --git a/Misc/NEWS b/Misc/NEWS index 4918265..b3795fd 100644 --- 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. -- cgit v0.12