@@ -36,6 +36,8 @@ class HTTPSConnection(_http_client.HTTPSConnection):
36
36
Connection class that enables usage of newer SSL protocols.
37
37
38
38
Reference: http://bugs.python.org/msg128686
39
+
40
+ NOTE: use https://check-tls.akamaized.net/ to check if (e.g.) TLS/SNI is working properly
39
41
"""
40
42
41
43
def __init__ (self , * args , ** kwargs ):
@@ -61,7 +63,7 @@ def create_sock():
61
63
62
64
# Reference(s): https://docs.python.org/2/library/ssl.html#ssl.SSLContext
63
65
# https://www.mnot.net/blog/2014/12/27/python_2_and_tls_sni
64
- if re .search (r"\A[\d.]+\Z" , conf . hostname or "" ) is None and kb .tlsSNI .get (conf . hostname ) is not False and hasattr (ssl , "SSLContext" ):
66
+ if re .search (r"\A[\d.]+\Z" , self . host or "" ) is None and kb .tlsSNI .get (self . host ) is not False and hasattr (ssl , "SSLContext" ):
65
67
for protocol in (_ for _ in _protocols if _ >= ssl .PROTOCOL_TLSv1 ):
66
68
try :
67
69
sock = create_sock ()
@@ -73,7 +75,7 @@ def create_sock():
73
75
_contexts [protocol ].set_ciphers ("DEFAULT@SECLEVEL=1" )
74
76
except ssl .SSLError :
75
77
pass
76
- result = _contexts [protocol ].wrap_socket (sock , do_handshake_on_connect = True , server_hostname = conf . hostname )
78
+ result = _contexts [protocol ].wrap_socket (sock , do_handshake_on_connect = True , server_hostname = self . host )
77
79
if result :
78
80
success = True
79
81
self .sock = result
@@ -86,8 +88,8 @@ def create_sock():
86
88
self ._tunnel_host = None
87
89
logger .debug ("SSL connection error occurred for '%s' ('%s')" % (_lut [protocol ], getSafeExString (ex )))
88
90
89
- if kb .tlsSNI .get (conf . hostname ) is None :
90
- kb .tlsSNI [conf . hostname ] = success
91
+ if kb .tlsSNI .get (self . host ) is None :
92
+ kb .tlsSNI [self . host ] = success
91
93
92
94
if not success :
93
95
for protocol in _protocols :
0 commit comments