Browse code

Revert "Prefer the stdlib SSLContext over urllib3 context"

This reverts commit f48af16ddc0daa262a2267da2c97e1c9af05f148.

Meant to push to 2.4.2

Toshio Kuratomi authored on 2017/10/24 23:32:33
Showing 1 changed files
... ...
@@ -698,13 +698,10 @@ class SSLValidationHandler(urllib_request.BaseHandler):
698 698
         return True
699 699
 
700 700
     def _make_context(self, to_add_ca_cert_path):
701
-        if HAS_SSLCONTEXT:
702
-            context = create_default_context()
703
-        elif HAS_URLLIB3_PYOPENSSLCONTEXT:
701
+        if HAS_URLLIB3_PYOPENSSLCONTEXT:
704 702
             context = PyOpenSSLContext(PROTOCOL)
705 703
         else:
706
-            raise NotImplementedError('Host libraries are too old to support creating an sslcontext')
707
-
704
+            context = create_default_context()
708 705
         if to_add_ca_cert_path:
709 706
             context.load_verify_locations(to_add_ca_cert_path)
710 707
         return context
... ...
@@ -713,11 +710,8 @@ class SSLValidationHandler(urllib_request.BaseHandler):
713 713
         tmp_ca_cert_path, to_add_ca_cert_path, paths_checked = self.get_ca_certs()
714 714
         https_proxy = os.environ.get('https_proxy')
715 715
         context = None
716
-        try:
716
+        if HAS_SSLCONTEXT or HAS_URLLIB3_PYOPENSSLCONTEXT:
717 717
             context = self._make_context(to_add_ca_cert_path)
718
-        except Exception:
719
-            # We'll make do with no context below
720
-            pass
721 718
 
722 719
         # Detect if 'no_proxy' environment variable is set and if our URL is included
723 720
         use_proxy = self.detect_no_proxy(req.get_full_url())