From b96a2e8fa765753e82eea531adb19716b52ca3ca Mon Sep 17 00:00:00 2001 From: liris Date: Mon, 20 Apr 2015 10:25:11 +0900 Subject: [PATCH] set check_hostname attribute before setiing verify_mode. --- websocket/_http.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket/_http.py b/websocket/_http.py index 9a2f7db..faec8b3 100644 --- a/websocket/_http.py +++ b/websocket/_http.py @@ -124,10 +124,11 @@ def _can_use_sni(): def _wrap_sni_socket(sock, sslopt, hostname, check_hostname): context = ssl.SSLContext(sslopt.get('ssl_version', ssl.PROTOCOL_SSLv23)) - context.load_verify_locations(cafile=sslopt.get('ca_certs', None)) - context.verify_mode = sslopt['cert_reqs'] + if HAVE_CONTEXT_CHECK_HOSTNAME: context.check_hostname = check_hostname + context.load_verify_locations(cafile=sslopt.get('ca_certs', None)) + context.verify_mode = sslopt['cert_reqs'] if 'ciphers' in sslopt: context.set_ciphers(sslopt['ciphers'])