##// END OF EJS Templates
sslutil: pass ui to _defaultcacerts...
Gregory Szorc -
r29483:918dce4b default
parent child Browse files
Show More
@@ -197,7 +197,7 b' def _hostsettings(ui, hostname):'
197 197 cafile)
198 198 else:
199 199 # CAs not defined in config. Try to find system bundles.
200 cafile = _defaultcacerts()
200 cafile = _defaultcacerts(ui)
201 201 if cafile:
202 202 ui.debug('using %s for CA file\n' % cafile)
203 203
@@ -430,7 +430,7 b' def _plainapplepython():'
430 430 return (exe.startswith('/usr/bin/python') or
431 431 exe.startswith('/system/library/frameworks/python.framework/'))
432 432
433 def _defaultcacerts():
433 def _defaultcacerts(ui):
434 434 """return path to default CA certificates or None."""
435 435 if _plainapplepython():
436 436 dummycert = os.path.join(os.path.dirname(__file__), 'dummycert.pem')
@@ -415,20 +415,22 b' def has_sslcontext():'
415 415
416 416 @check("defaultcacerts", "can verify SSL certs by system's CA certs store")
417 417 def has_defaultcacerts():
418 from mercurial import sslutil
419 return sslutil._defaultcacerts() or sslutil._canloaddefaultcerts
418 from mercurial import sslutil, ui as uimod
419 ui = uimod.ui()
420 return sslutil._defaultcacerts(ui) or sslutil._canloaddefaultcerts
420 421
421 422 @check("defaultcacertsloaded", "detected presence of loaded system CA certs")
422 423 def has_defaultcacertsloaded():
423 424 import ssl
424 from mercurial import sslutil
425 from mercurial import sslutil, ui as uimod
425 426
426 427 if not has_defaultcacerts():
427 428 return False
428 429 if not has_sslcontext():
429 430 return False
430 431
431 cafile = sslutil._defaultcacerts()
432 ui = uimod.ui()
433 cafile = sslutil._defaultcacerts(ui)
432 434 ctx = ssl.create_default_context()
433 435 if cafile:
434 436 ctx.load_verify_locations(cafile=cafile)
General Comments 0
You need to be logged in to leave comments. Login now