Mercurial > hg-stable
changeset 29483:918dce4b8c26
sslutil: pass ui to _defaultcacerts
We'll use this shortly.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 01 Jul 2016 19:04:39 -0700 |
parents | 4e72995f6c9c |
children | 53b7fc7cc2bb |
files | mercurial/sslutil.py tests/hghave.py |
diffstat | 2 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/sslutil.py Fri Jul 01 18:03:51 2016 -0700 +++ b/mercurial/sslutil.py Fri Jul 01 19:04:39 2016 -0700 @@ -197,7 +197,7 @@ cafile) else: # CAs not defined in config. Try to find system bundles. - cafile = _defaultcacerts() + cafile = _defaultcacerts(ui) if cafile: ui.debug('using %s for CA file\n' % cafile) @@ -430,7 +430,7 @@ return (exe.startswith('/usr/bin/python') or exe.startswith('/system/library/frameworks/python.framework/')) -def _defaultcacerts(): +def _defaultcacerts(ui): """return path to default CA certificates or None.""" if _plainapplepython(): dummycert = os.path.join(os.path.dirname(__file__), 'dummycert.pem')
--- a/tests/hghave.py Fri Jul 01 18:03:51 2016 -0700 +++ b/tests/hghave.py Fri Jul 01 19:04:39 2016 -0700 @@ -415,20 +415,22 @@ @check("defaultcacerts", "can verify SSL certs by system's CA certs store") def has_defaultcacerts(): - from mercurial import sslutil - return sslutil._defaultcacerts() or sslutil._canloaddefaultcerts + from mercurial import sslutil, ui as uimod + ui = uimod.ui() + return sslutil._defaultcacerts(ui) or sslutil._canloaddefaultcerts @check("defaultcacertsloaded", "detected presence of loaded system CA certs") def has_defaultcacertsloaded(): import ssl - from mercurial import sslutil + from mercurial import sslutil, ui as uimod if not has_defaultcacerts(): return False if not has_sslcontext(): return False - cafile = sslutil._defaultcacerts() + ui = uimod.ui() + cafile = sslutil._defaultcacerts(ui) ctx = ssl.create_default_context() if cafile: ctx.load_verify_locations(cafile=cafile)