]> granicus.if.org Git - python/commitdiff
also use openssl envvars to find certs on windows (closes #22449)
authorBenjamin Peterson <benjamin@python.org>
Fri, 3 Oct 2014 21:27:05 +0000 (17:27 -0400)
committerBenjamin Peterson <benjamin@python.org>
Fri, 3 Oct 2014 21:27:05 +0000 (17:27 -0400)
Patch by Christian Heimes and Alex Gaynor.

Lib/ssl.py
Lib/test/test_ssl.py
Misc/NEWS

index d3c18ed1b7936b1eea54635f05cf51c62b1d99b0..d9d191628cd15e98ba2f1059f745d6f82731bd8f 100644 (file)
@@ -390,8 +390,7 @@ class SSLContext(_SSLContext):
         if sys.platform == "win32":
             for storename in self._windows_cert_stores:
                 self._load_windows_store_certs(storename, purpose)
-        else:
-            self.set_default_verify_paths()
+        self.set_default_verify_paths()
 
 
 def create_default_context(purpose=Purpose.SERVER_AUTH, *, cafile=None,
index d1cf5b27945bd3f191a36bf73a5257be730cc021..c2a4f0e8111babbe7d44f804873755a51adc1fc1 100644 (file)
@@ -1016,6 +1016,14 @@ class ContextTests(unittest.TestCase):
         self.assertRaises(TypeError, ctx.load_default_certs, None)
         self.assertRaises(TypeError, ctx.load_default_certs, 'SERVER_AUTH')
 
+    def test_load_default_certs_env(self):
+        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        with support.EnvironmentVarGuard() as env:
+            env["SSL_CERT_DIR"] = CAPATH
+            env["SSL_CERT_FILE"] = CERTFILE
+            ctx.load_default_certs()
+            self.assertEqual(ctx.cert_store_stats(), {"crl": 0, "x509": 1, "x509_ca": 0})
+
     def test_create_default_context(self):
         ctx = ssl.create_default_context()
         self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23)
index 8602e8d7bfd135fff952067d14ea86c28aae513c..5934d5bc32478e6c6adbbe5cccdc987463c8c817 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -19,6 +19,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #22449: In the ssl.SSLContext.load_default_certs, consult the
+  enviromental variables SSL_CERT_DIR and SSL_CERT_FILE on Windows.
+
 - Issue #20076: Added non derived UTF-8 aliases to locale aliases table.
 
 - Issue #20079: Added locales supported in glibc 2.18 to locale alias table.