Show More
@@ -18,10 +18,9 b' try:' | |||||
18 | try: |
|
18 | try: | |
19 | ssl_context = ssl.SSLContext |
|
19 | ssl_context = ssl.SSLContext | |
20 |
|
20 | |||
21 |
def ssl_wrap_socket(sock, keyfile, certfile, |
|
21 | def ssl_wrap_socket(sock, keyfile, certfile, cert_reqs=ssl.CERT_NONE, | |
22 |
|
|
22 | ca_certs=None, serverhostname=None): | |
23 | serverhostname=None): |
|
23 | sslcontext = ssl.SSLContext(PROTOCOL_TLSv1) | |
24 | sslcontext = ssl.SSLContext(ssl_version) |
|
|||
25 | if certfile is not None: |
|
24 | if certfile is not None: | |
26 | sslcontext.load_cert_chain(certfile, keyfile) |
|
25 | sslcontext.load_cert_chain(certfile, keyfile) | |
27 | sslcontext.verify_mode = cert_reqs |
|
26 | sslcontext.verify_mode = cert_reqs | |
@@ -37,12 +36,11 b' try:' | |||||
37 | raise util.Abort(_('ssl connection failed')) |
|
36 | raise util.Abort(_('ssl connection failed')) | |
38 | return sslsocket |
|
37 | return sslsocket | |
39 | except AttributeError: |
|
38 | except AttributeError: | |
40 |
def ssl_wrap_socket(sock, keyfile, certfile, |
|
39 | def ssl_wrap_socket(sock, keyfile, certfile, cert_reqs=ssl.CERT_NONE, | |
41 |
|
|
40 | ca_certs=None, serverhostname=None): | |
42 | serverhostname=None): |
|
|||
43 | sslsocket = ssl.wrap_socket(sock, keyfile, certfile, |
|
41 | sslsocket = ssl.wrap_socket(sock, keyfile, certfile, | |
44 | cert_reqs=cert_reqs, ca_certs=ca_certs, |
|
42 | cert_reqs=cert_reqs, ca_certs=ca_certs, | |
45 |
ssl_version= |
|
43 | ssl_version=PROTOCOL_TLSv1) | |
46 | # check if wrap_socket failed silently because socket had been |
|
44 | # check if wrap_socket failed silently because socket had been | |
47 | # closed |
|
45 | # closed | |
48 | # - see http://bugs.python.org/issue13721 |
|
46 | # - see http://bugs.python.org/issue13721 | |
@@ -56,9 +54,8 b' except ImportError:' | |||||
56 |
|
54 | |||
57 | import socket, httplib |
|
55 | import socket, httplib | |
58 |
|
56 | |||
59 |
def ssl_wrap_socket(sock, keyfile, certfile, |
|
57 | def ssl_wrap_socket(sock, keyfile, certfile, cert_reqs=CERT_REQUIRED, | |
60 |
|
|
58 | ca_certs=None, serverhostname=None): | |
61 | serverhostname=None): |
|
|||
62 | if not util.safehasattr(socket, 'ssl'): |
|
59 | if not util.safehasattr(socket, 'ssl'): | |
63 | raise util.Abort(_('Python SSL support not found')) |
|
60 | raise util.Abort(_('Python SSL support not found')) | |
64 | if ca_certs: |
|
61 | if ca_certs: | |
@@ -126,8 +123,7 b' def _plainapplepython():' | |||||
126 | exe.startswith('/system/library/frameworks/python.framework/')) |
|
123 | exe.startswith('/system/library/frameworks/python.framework/')) | |
127 |
|
124 | |||
128 | def sslkwargs(ui, host): |
|
125 | def sslkwargs(ui, host): | |
129 | kws = {'ssl_version': PROTOCOL_TLSv1, |
|
126 | kws = {} | |
130 | } |
|
|||
131 | hostfingerprint = ui.config('hostfingerprints', host) |
|
127 | hostfingerprint = ui.config('hostfingerprints', host) | |
132 | if hostfingerprint: |
|
128 | if hostfingerprint: | |
133 | return kws |
|
129 | return kws |
General Comments 0
You need to be logged in to leave comments.
Login now