summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCory Benfield <lukasaoz@gmail.com>2016-01-25 18:30:00 +0000
committerCory Benfield <lukasaoz@gmail.com>2016-01-25 18:30:00 +0000
commite6e3847e9c6f5870702d48d3f23da36e162962e4 (patch)
tree9f093d73428f991017ebfb459c0ddefbf834f698
parent9efd6e65e59f94ffaf66d68e6316a5583c9bfff2 (diff)
downloadurllib3-e6e3847e9c6f5870702d48d3f23da36e162962e4.tar.gz
Only send bytestrings to PyOpenSSL
-rw-r--r--urllib3/contrib/pyopenssl.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/urllib3/contrib/pyopenssl.py b/urllib3/contrib/pyopenssl.py
index 9cdc5ec3..232dc760 100644
--- a/urllib3/contrib/pyopenssl.py
+++ b/urllib3/contrib/pyopenssl.py
@@ -65,6 +65,7 @@ except ImportError: # Platform-specific: Python 3
import ssl
import select
+import six
from .. import connection
from .. import util
@@ -341,6 +342,8 @@ def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None,
ctx.set_cipher_list(DEFAULT_SSL_CIPHER_LIST)
cnx = OpenSSL.SSL.Connection(ctx, sock)
+ if isinstance(server_hostname, six.text_type): # Platform-specific: Python 3
+ server_hostname = server_hostname.encode('utf-8')
cnx.set_tlsext_host_name(server_hostname)
cnx.set_connect_state()
while True: