Patchwork [4,of,8] sslutil: don't attempt to find default CA certs file when told not to

mail settings
Submitter Gregory Szorc
Date July 2, 2016, 2:57 a.m.
Message ID <ab3d545871efb2e0405d.1467428260@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/15719/
State Accepted
Delegated to: Yuya Nishihara
Headers show


Gregory Szorc - July 2, 2016, 2:57 a.m.
# HG changeset patch
# User Gregory Szorc <>
# Date 1467425865 25200
#      Fri Jul 01 19:17:45 2016 -0700
# Node ID ab3d545871efb2e0405d576f3bda1c935d6b6d31
# Parent  dc05122ccfcf77c65984f3196089f86472a6dd17
sslutil: don't attempt to find default CA certs file when told not to

Before, devel.disableloaddefaultcerts only impacted the loading of
default certs via SSLContext. After this patch, the config option also
prevents sslutil._defaultcacerts() from being called.

This config option is meant to be used by tests to force no CA certs
to be loaded. Future patches will enable _defaultcacerts() to have
success more often. Without this change we can't reliably test the
failure to load CA certs. (This patch also likely fixes test failures
on some OS X configurations.)


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -190,17 +190,17 @@  def _hostsettings(ui, hostname):
             # Find global certificates file in config.
             cafile = ui.config('web', 'cacerts')
             if cafile:
                 cafile = util.expandpath(cafile)
                 if not os.path.exists(cafile):
                     raise error.Abort(_('could not find web.cacerts: %s') %
-            else:
+            elif s['allowloaddefaultcerts']:
                 # CAs not defined in config. Try to find system bundles.
                 cafile = _defaultcacerts(ui)
                 if cafile:
                     ui.debug('using %s for CA file\n' % cafile)
             s['cafile'] = cafile
         # Require certificate validation if CA certs are being loaded and