##// END OF EJS Templates
sslutil: move _canloaddefaultcerts logic...
Gregory Szorc -
r28650:737863b0 default
parent child Browse files
Show More
@@ -41,8 +41,10 b' try:'
41 # SSL/TLS features are available.
41 # SSL/TLS features are available.
42 SSLContext = ssl.SSLContext
42 SSLContext = ssl.SSLContext
43 modernssl = True
43 modernssl = True
44 _canloaddefaultcerts = util.safehasattr(SSLContext, 'load_default_certs')
44 except AttributeError:
45 except AttributeError:
45 modernssl = False
46 modernssl = False
47 _canloaddefaultcerts = False
46
48
47 # We implement SSLContext using the interface from the standard library.
49 # We implement SSLContext using the interface from the standard library.
48 class SSLContext(object):
50 class SSLContext(object):
@@ -104,12 +106,10 b' except AttributeError:'
104
106
105 return ssl.wrap_socket(socket, **args)
107 return ssl.wrap_socket(socket, **args)
106
108
107 _canloaddefaultcerts = False
108 try:
109 try:
109 # ssl.SSLContext was added in 2.7.9 and presence indicates modern
110 # ssl.SSLContext was added in 2.7.9 and presence indicates modern
110 # SSL/TLS features are available.
111 # SSL/TLS features are available.
111 ssl_context = ssl.SSLContext
112 ssl_context = ssl.SSLContext
112 _canloaddefaultcerts = util.safehasattr(ssl_context, 'load_default_certs')
113
113
114 def wrapsocket(sock, keyfile, certfile, ui, cert_reqs=ssl.CERT_NONE,
114 def wrapsocket(sock, keyfile, certfile, ui, cert_reqs=ssl.CERT_NONE,
115 ca_certs=None, serverhostname=None):
115 ca_certs=None, serverhostname=None):
General Comments 0
You need to be logged in to leave comments. Login now