Mercurial > public > mercurial-scm > hg
diff mercurial/sslutil.py @ 29499:9c5325c79683
sslutil: issue warning when unable to load certificates on OS X
Previously, failure to load system certificates on OS X would lead
to a certificate verify failure and that's it. We now print a warning
message with a URL that will contain information on how to configure
certificates on OS X.
As the inline comment states, there is room to improve here. I think
we could try harder to detect Homebrew and MacPorts installed
certificate files, for example. It's worth noting that Homebrew's
openssl package uses `security find-certificate -a -p` during package
installation to export the system keychain root CAs to
etc/openssl/cert.pem. This is something we could consider adding
to setup.py. We could also encourage packagers to do this. For now,
I'd just like to get this warning (which matches Windows behavior)
landed. We should have time to improve things before release.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 06 Jul 2016 20:46:05 -0700 |
parents | 54ad81b0665f |
children | 4b16a5bd9948 |
line wrap: on
line diff
--- a/mercurial/sslutil.py Thu Jun 30 08:38:19 2016 -0700 +++ b/mercurial/sslutil.py Wed Jul 06 20:46:05 2016 -0700 @@ -468,6 +468,18 @@ if os.path.exists(dummycert): return dummycert + # The Apple OpenSSL trick isn't available to us. If Python isn't able to + # load system certs, we're out of luck. + if sys.platform == 'darwin': + # FUTURE Consider looking for Homebrew or MacPorts installed certs + # files. Also consider exporting the keychain certs to a file during + # Mercurial install. + if not _canloaddefaultcerts: + ui.warn(_('(unable to load CA certificates; see ' + 'https://mercurial-scm.org/wiki/SecureConnections for ' + 'how to configure Mercurial to avoid this message)\n')) + return None + return None def validatesocket(sock):