322 if os.path.exists(dummycert): |
322 if os.path.exists(dummycert): |
323 return dummycert |
323 return dummycert |
324 |
324 |
325 return None |
325 return None |
326 |
326 |
327 def validatesocket(sock, strict=False): |
327 def validatesocket(sock): |
328 """Validate a socket meets security requiremnets. |
328 """Validate a socket meets security requiremnets. |
329 |
329 |
330 The passed socket must have been created with ``wrapsocket()``. |
330 The passed socket must have been created with ``wrapsocket()``. |
331 """ |
331 """ |
332 host = sock._hgstate['hostname'] |
332 host = sock._hgstate['hostname'] |
384 'config setting)\n') % |
384 'config setting)\n') % |
385 (host, nicefingerprint, section)) |
385 (host, nicefingerprint, section)) |
386 return |
386 return |
387 |
387 |
388 if not sock._hgstate['caloaded']: |
388 if not sock._hgstate['caloaded']: |
389 if strict: |
389 ui.warn(_('warning: %s certificate with fingerprint %s ' |
390 raise error.Abort(_('%s certificate with fingerprint %s not ' |
390 'not verified (check %s or web.cacerts config ' |
391 'verified') % (host, nicefingerprint), |
391 'setting)\n') % |
392 hint=_('check %s or web.cacerts config ' |
392 (host, nicefingerprint, section)) |
393 'setting') % section) |
|
394 else: |
|
395 ui.warn(_('warning: %s certificate with fingerprint %s ' |
|
396 'not verified (check %s or web.cacerts config ' |
|
397 'setting)\n') % |
|
398 (host, nicefingerprint, section)) |
|
399 |
|
400 return |
393 return |
401 |
394 |
402 msg = _verifycert(peercert2, host) |
395 msg = _verifycert(peercert2, host) |
403 if msg: |
396 if msg: |
404 raise error.Abort(_('%s certificate error: %s') % (host, msg), |
397 raise error.Abort(_('%s certificate error: %s') % (host, msg), |