Show More
@@ -285,5 +285,6 b' class http2handler(urlreq.httphandler, u' | |||||
285 | con = HTTPConnection(host, port, use_ssl=True, |
|
285 | con = HTTPConnection(host, port, use_ssl=True, | |
286 | ssl_wrap_socket=sslutil.wrapsocket, |
|
286 | ssl_wrap_socket=sslutil.wrapsocket, | |
287 | ssl_validator=sslutil.validatesocket, |
|
287 | ssl_validator=sslutil.validatesocket, | |
|
288 | ui=self.ui, | |||
288 | **kwargs) |
|
289 | **kwargs) | |
289 | return con |
|
290 | return con |
@@ -48,8 +48,9 b' class STARTTLS(smtplib.SMTP):' | |||||
48 |
|
48 | |||
49 | This class allows to pass any keyword arguments to SSL socket creation. |
|
49 | This class allows to pass any keyword arguments to SSL socket creation. | |
50 | ''' |
|
50 | ''' | |
51 | def __init__(self, sslkwargs, host=None, **kwargs): |
|
51 | def __init__(self, ui, sslkwargs, host=None, **kwargs): | |
52 | smtplib.SMTP.__init__(self, **kwargs) |
|
52 | smtplib.SMTP.__init__(self, **kwargs) | |
|
53 | self._ui = ui | |||
53 | self._sslkwargs = sslkwargs |
|
54 | self._sslkwargs = sslkwargs | |
54 | self._host = host |
|
55 | self._host = host | |
55 |
|
56 | |||
@@ -60,6 +61,7 b' class STARTTLS(smtplib.SMTP):' | |||||
60 | (resp, reply) = self.docmd("STARTTLS") |
|
61 | (resp, reply) = self.docmd("STARTTLS") | |
61 | if resp == 220: |
|
62 | if resp == 220: | |
62 | self.sock = sslutil.wrapsocket(self.sock, keyfile, certfile, |
|
63 | self.sock = sslutil.wrapsocket(self.sock, keyfile, certfile, | |
|
64 | ui=self._ui, | |||
63 | serverhostname=self._host, |
|
65 | serverhostname=self._host, | |
64 | **self._sslkwargs) |
|
66 | **self._sslkwargs) | |
65 | self.file = smtplib.SSLFakeFile(self.sock) |
|
67 | self.file = smtplib.SSLFakeFile(self.sock) | |
@@ -74,13 +76,14 b' class SMTPS(smtplib.SMTP):' | |||||
74 |
|
76 | |||
75 | This class allows to pass any keyword arguments to SSL socket creation. |
|
77 | This class allows to pass any keyword arguments to SSL socket creation. | |
76 | ''' |
|
78 | ''' | |
77 | def __init__(self, sslkwargs, keyfile=None, certfile=None, host=None, |
|
79 | def __init__(self, ui, sslkwargs, keyfile=None, certfile=None, host=None, | |
78 | **kwargs): |
|
80 | **kwargs): | |
79 | self.keyfile = keyfile |
|
81 | self.keyfile = keyfile | |
80 | self.certfile = certfile |
|
82 | self.certfile = certfile | |
81 | smtplib.SMTP.__init__(self, **kwargs) |
|
83 | smtplib.SMTP.__init__(self, **kwargs) | |
82 | self._host = host |
|
84 | self._host = host | |
83 | self.default_port = smtplib.SMTP_SSL_PORT |
|
85 | self.default_port = smtplib.SMTP_SSL_PORT | |
|
86 | self._ui = ui | |||
84 | self._sslkwargs = sslkwargs |
|
87 | self._sslkwargs = sslkwargs | |
85 |
|
88 | |||
86 | def _get_socket(self, host, port, timeout): |
|
89 | def _get_socket(self, host, port, timeout): | |
@@ -89,6 +92,7 b' class SMTPS(smtplib.SMTP):' | |||||
89 | new_socket = socket.create_connection((host, port), timeout) |
|
92 | new_socket = socket.create_connection((host, port), timeout) | |
90 | new_socket = sslutil.wrapsocket(new_socket, |
|
93 | new_socket = sslutil.wrapsocket(new_socket, | |
91 | self.keyfile, self.certfile, |
|
94 | self.keyfile, self.certfile, | |
|
95 | ui=self._ui, | |||
92 | serverhostname=self._host, |
|
96 | serverhostname=self._host, | |
93 | **self._sslkwargs) |
|
97 | **self._sslkwargs) | |
94 | self.file = smtplib.SSLFakeFile(new_socket) |
|
98 | self.file = smtplib.SSLFakeFile(new_socket) | |
@@ -115,13 +119,14 b' def _smtp(ui):' | |||||
115 | if (starttls or smtps) and verifycert: |
|
119 | if (starttls or smtps) and verifycert: | |
116 | sslkwargs = sslutil.sslkwargs(ui, mailhost) |
|
120 | sslkwargs = sslutil.sslkwargs(ui, mailhost) | |
117 | else: |
|
121 | else: | |
118 | # 'ui' is required by sslutil.wrapsocket() and set by sslkwargs() |
|
122 | sslkwargs = {} | |
119 | sslkwargs = {'ui': ui} |
|
123 | ||
120 | if smtps: |
|
124 | if smtps: | |
121 | ui.note(_('(using smtps)\n')) |
|
125 | ui.note(_('(using smtps)\n')) | |
122 | s = SMTPS(sslkwargs, local_hostname=local_hostname, host=mailhost) |
|
126 | s = SMTPS(ui, sslkwargs, local_hostname=local_hostname, host=mailhost) | |
123 | elif starttls: |
|
127 | elif starttls: | |
124 |
s = STARTTLS(sslkwargs, local_hostname=local_hostname, |
|
128 | s = STARTTLS(ui, sslkwargs, local_hostname=local_hostname, | |
|
129 | host=mailhost) | |||
125 | else: |
|
130 | else: | |
126 | s = smtplib.SMTP(local_hostname=local_hostname) |
|
131 | s = smtplib.SMTP(local_hostname=local_hostname) | |
127 | if smtps: |
|
132 | if smtps: |
@@ -247,7 +247,7 b' def sslkwargs(ui, host):' | |||||
247 |
|
247 | |||
248 | ``host`` is the hostname being connected to. |
|
248 | ``host`` is the hostname being connected to. | |
249 | """ |
|
249 | """ | |
250 |
kws = { |
|
250 | kws = {} | |
251 |
|
251 | |||
252 | # If a host key fingerprint is on file, it is the only thing that matters |
|
252 | # If a host key fingerprint is on file, it is the only thing that matters | |
253 | # and CA certs don't come into play. |
|
253 | # and CA certs don't come into play. |
@@ -354,8 +354,8 b' if has_https:' | |||||
354 | _generic_proxytunnel(self) |
|
354 | _generic_proxytunnel(self) | |
355 | host = self.realhostport.rsplit(':', 1)[0] |
|
355 | host = self.realhostport.rsplit(':', 1)[0] | |
356 | self.sock = sslutil.wrapsocket( |
|
356 | self.sock = sslutil.wrapsocket( | |
357 |
self.sock, self.key_file, self.cert_file, |
|
357 | self.sock, self.key_file, self.cert_file, ui=self.ui, | |
358 | **sslutil.sslkwargs(self.ui, host)) |
|
358 | serverhostname=host, **sslutil.sslkwargs(self.ui, host)) | |
359 | sslutil.validatesocket(self.sock) |
|
359 | sslutil.validatesocket(self.sock) | |
360 |
|
360 | |||
361 | class httpshandler(keepalive.KeepAliveHandler, urlreq.httpshandler): |
|
361 | class httpshandler(keepalive.KeepAliveHandler, urlreq.httpshandler): |
General Comments 0
You need to be logged in to leave comments.
Login now