Show More
@@ -277,7 +277,7 b' class http2handler(urllib2.HTTPHandler, ' | |||||
277 | kwargs.update(sslutil.sslkwargs(self.ui, host)) |
|
277 | kwargs.update(sslutil.sslkwargs(self.ui, host)) | |
278 |
|
278 | |||
279 | con = HTTPConnection(host, port, use_ssl=True, |
|
279 | con = HTTPConnection(host, port, use_ssl=True, | |
280 |
ssl_wrap_socket=sslutil. |
|
280 | ssl_wrap_socket=sslutil.wrapsocket, | |
281 | ssl_validator=sslutil.validator(self.ui, host), |
|
281 | ssl_validator=sslutil.validator(self.ui, host), | |
282 | **kwargs) |
|
282 | **kwargs) | |
283 | return con |
|
283 | return con |
@@ -45,8 +45,8 b' class STARTTLS(smtplib.SMTP):' | |||||
45 | raise smtplib.SMTPException(msg) |
|
45 | raise smtplib.SMTPException(msg) | |
46 | (resp, reply) = self.docmd("STARTTLS") |
|
46 | (resp, reply) = self.docmd("STARTTLS") | |
47 | if resp == 220: |
|
47 | if resp == 220: | |
48 |
self.sock = sslutil. |
|
48 | self.sock = sslutil.wrapsocket(self.sock, keyfile, certfile, | |
49 |
|
|
49 | **self._sslkwargs) | |
50 | if not util.safehasattr(self.sock, "read"): |
|
50 | if not util.safehasattr(self.sock, "read"): | |
51 | # using httplib.FakeSocket with Python 2.5.x or earlier |
|
51 | # using httplib.FakeSocket with Python 2.5.x or earlier | |
52 | self.sock.read = self.sock.recv |
|
52 | self.sock.read = self.sock.recv | |
@@ -74,9 +74,9 b" if util.safehasattr(smtplib.SMTP, '_get_" | |||||
74 | if self.debuglevel > 0: |
|
74 | if self.debuglevel > 0: | |
75 | print >> sys.stderr, 'connect:', (host, port) |
|
75 | print >> sys.stderr, 'connect:', (host, port) | |
76 | new_socket = socket.create_connection((host, port), timeout) |
|
76 | new_socket = socket.create_connection((host, port), timeout) | |
77 |
new_socket = sslutil. |
|
77 | new_socket = sslutil.wrapsocket(new_socket, | |
78 |
|
|
78 | self.keyfile, self.certfile, | |
79 |
|
|
79 | **self._sslkwargs) | |
80 | self.file = smtplib.SSLFakeFile(new_socket) |
|
80 | self.file = smtplib.SSLFakeFile(new_socket) | |
81 | return new_socket |
|
81 | return new_socket | |
82 | else: |
|
82 | else: |
@@ -21,9 +21,9 b' try:' | |||||
21 | _canloaddefaultcerts = util.safehasattr(ssl_context, |
|
21 | _canloaddefaultcerts = util.safehasattr(ssl_context, | |
22 | 'load_default_certs') |
|
22 | 'load_default_certs') | |
23 |
|
23 | |||
24 |
def |
|
24 | def wrapsocket(sock, keyfile, certfile, ui, | |
25 |
|
|
25 | cert_reqs=ssl.CERT_NONE, | |
26 |
|
|
26 | ca_certs=None, serverhostname=None): | |
27 | # Allow any version of SSL starting with TLSv1 and |
|
27 | # Allow any version of SSL starting with TLSv1 and | |
28 | # up. Note that specifying TLSv1 here prohibits use of |
|
28 | # up. Note that specifying TLSv1 here prohibits use of | |
29 | # newer standards (like TLSv1_2), so this is the right way |
|
29 | # newer standards (like TLSv1_2), so this is the right way | |
@@ -55,9 +55,9 b' try:' | |||||
55 | raise util.Abort(_('ssl connection failed')) |
|
55 | raise util.Abort(_('ssl connection failed')) | |
56 | return sslsocket |
|
56 | return sslsocket | |
57 | except AttributeError: |
|
57 | except AttributeError: | |
58 |
def |
|
58 | def wrapsocket(sock, keyfile, certfile, ui, | |
59 |
|
|
59 | cert_reqs=ssl.CERT_NONE, | |
60 |
|
|
60 | ca_certs=None, serverhostname=None): | |
61 | sslsocket = ssl.wrap_socket(sock, keyfile, certfile, |
|
61 | sslsocket = ssl.wrap_socket(sock, keyfile, certfile, | |
62 | cert_reqs=cert_reqs, ca_certs=ca_certs, |
|
62 | cert_reqs=cert_reqs, ca_certs=ca_certs, | |
63 | ssl_version=ssl.PROTOCOL_TLSv1) |
|
63 | ssl_version=ssl.PROTOCOL_TLSv1) | |
@@ -72,9 +72,9 b' except ImportError:' | |||||
72 |
|
72 | |||
73 | import socket, httplib |
|
73 | import socket, httplib | |
74 |
|
74 | |||
75 |
def |
|
75 | def wrapsocket(sock, keyfile, certfile, ui, | |
76 |
|
|
76 | cert_reqs=CERT_REQUIRED, | |
77 |
|
|
77 | ca_certs=None, serverhostname=None): | |
78 | if not util.safehasattr(socket, 'ssl'): |
|
78 | if not util.safehasattr(socket, 'ssl'): | |
79 | raise util.Abort(_('Python SSL support not found')) |
|
79 | raise util.Abort(_('Python SSL support not found')) | |
80 | if ca_certs: |
|
80 | if ca_certs: |
@@ -175,8 +175,8 b' class httpconnection(keepalive.HTTPConne' | |||||
175 | self.sock.connect((self.host, self.port)) |
|
175 | self.sock.connect((self.host, self.port)) | |
176 | if _generic_proxytunnel(self): |
|
176 | if _generic_proxytunnel(self): | |
177 | # we do not support client X.509 certificates |
|
177 | # we do not support client X.509 certificates | |
178 |
self.sock = sslutil. |
|
178 | self.sock = sslutil.wrapsocket(self.sock, None, None, None, | |
179 |
|
|
179 | serverhostname=self.host) | |
180 | else: |
|
180 | else: | |
181 | keepalive.HTTPConnection.connect(self) |
|
181 | keepalive.HTTPConnection.connect(self) | |
182 |
|
182 | |||
@@ -338,7 +338,7 b' if has_https:' | |||||
338 | if self.realhostport: # use CONNECT proxy |
|
338 | if self.realhostport: # use CONNECT proxy | |
339 | _generic_proxytunnel(self) |
|
339 | _generic_proxytunnel(self) | |
340 | host = self.realhostport.rsplit(':', 1)[0] |
|
340 | host = self.realhostport.rsplit(':', 1)[0] | |
341 |
self.sock = sslutil. |
|
341 | self.sock = sslutil.wrapsocket( | |
342 | self.sock, self.key_file, self.cert_file, serverhostname=host, |
|
342 | self.sock, self.key_file, self.cert_file, serverhostname=host, | |
343 | **sslutil.sslkwargs(self.ui, host)) |
|
343 | **sslutil.sslkwargs(self.ui, host)) | |
344 | sslutil.validator(self.ui, host)(self.sock) |
|
344 | sslutil.validator(self.ui, host)(self.sock) |
General Comments 0
You need to be logged in to leave comments.
Login now