Blob Blame History Raw
From 04b6d11d7745b319fad127622f45bfb99759a8d7 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcritten@redhat.com>
Date: Tue, 17 May 2016 14:02:24 -0400
Subject: [PATCH] Work around missing ndg-httpsclient breaking import of
 pyopenssl

---
 test/test_request.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/test/test_request.py b/test/test_request.py
index 5d2a525..254b31c 100644
--- a/test/test_request.py
+++ b/test/test_request.py
@@ -8,8 +8,13 @@ import logging
 import socket
 from requests.packages.urllib3.util import get_host
 from requests.packages.urllib3.util.timeout import Timeout
-from requests.packages.urllib3.contrib import pyopenssl
 from requests.packages.urllib3.connectionpool import HTTPConnectionPool, HTTPSConnectionPool, VerifiedHTTPSConnection 
+try:
+    from requests.packages.urllib3.contrib.pyopenssl import DEFAULT_SSL_CIPHER_LIST
+except ImportError:
+    DEFAULT_SSL_CIPHER_LIST = "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:" + \
+    "ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:" + \
+    "!aNULL:!MD5:!DSS"
 
 # Don't bend over backwards for ssl support, assume it is there.
 import ssl
@@ -33,7 +38,7 @@ except ImportError:
         # Other older python we use the urllib3 bundled copy
 		from urllib3.packages.ssl_match_hostname import match_hostname, CertificateError
 
-SAVE_DEFAULT_SSL_CIPHER_LIST = pyopenssl.DEFAULT_SSL_CIPHER_LIST
+SAVE_DEFAULT_SSL_CIPHER_LIST = DEFAULT_SSL_CIPHER_LIST
 
 log = logging.getLogger(__name__)
 
@@ -141,9 +146,9 @@ class MyVerifiedHTTPSConnection(VerifiedHTTPSConnection):
     def connect(self):
         if self.sni:
             if self.ciphers:
-                pyopenssl.DEFAULT_SSL_CIPHER_LIST = self.ciphers
+                DEFAULT_SSL_CIPHER_LIST = self.ciphers
             else:
-                pyopenssl.DEFAULT_SSL_CIPHER_LIST = SAVE_DEFAULT_SSL_CIPHER_LIST
+                DEFAULT_SSL_CIPHER_LIST = SAVE_DEFAULT_SSL_CIPHER_LIST
             return super(MyVerifiedHTTPSConnection, self).connect()
 
         # Add certificate verification
-- 
2.5.5