##// END OF EJS Templates
sslutil: convert socket validation from a class to a function (API)...
Gregory Szorc -
r29227:dffe78d8 default
parent child Browse files
Show More
@@ -284,6 +284,6 b' class http2handler(urlreq.httphandler, u'
284 284
285 285 con = HTTPConnection(host, port, use_ssl=True,
286 286 ssl_wrap_socket=sslutil.wrapsocket,
287 ssl_validator=sslutil.validator(self.ui, host),
287 ssl_validator=sslutil.validatesocket,
288 288 **kwargs)
289 289 return con
@@ -139,7 +139,7 b' def _smtp(ui):'
139 139 s.ehlo()
140 140 if (starttls or smtps) and verifycert:
141 141 ui.note(_('(verifying remote certificate)\n'))
142 sslutil.validator(ui, mailhost)(s.sock, verifycert == 'strict')
142 sslutil.validatesocket(s.sock, verifycert == 'strict')
143 143 username = ui.config('smtp', 'username')
144 144 password = ui.config('smtp', 'password')
145 145 if username and not password:
@@ -291,11 +291,11 b' def sslkwargs(ui, host):'
291 291
292 292 return kws
293 293
294 class validator(object):
295 def __init__(self, ui=None, host=None):
296 pass
294 def validatesocket(sock, strict=False):
295 """Validate a socket meets security requiremnets.
297 296
298 def __call__(self, sock, strict=False):
297 The passed socket must have been created with ``wrapsocket()``.
298 """
299 299 host = sock._hgstate['hostname']
300 300 ui = sock._hgstate['ui']
301 301
@@ -356,7 +356,7 b' if has_https:'
356 356 self.sock = sslutil.wrapsocket(
357 357 self.sock, self.key_file, self.cert_file, serverhostname=host,
358 358 **sslutil.sslkwargs(self.ui, host))
359 sslutil.validator(self.ui, host)(self.sock)
359 sslutil.validatesocket(self.sock)
360 360
361 361 class httpshandler(keepalive.KeepAliveHandler, urlreq.httpshandler):
362 362 def __init__(self, ui):
General Comments 0
You need to be logged in to leave comments. Login now