Comments
Patch
@@ -442,16 +442,29 @@ def _defaultcacerts(ui):
try:
import certifi
certs = certifi.where()
ui.debug('using ca certificates from certifi\n')
return certs
except ImportError:
pass
+ # On Windows, only the modern ssl module is capable of loading the system
+ # CA certificates. If we're not capable of doing that, emit a warning
+ # because we'll get a certificate verification error later and the lack
+ # of loaded CA certificates will be the reason why.
+ # Assertion: this code is only called if certificates are being verified.
+ if os.name == 'nt':
+ if not _canloaddefaultcerts:
+ ui.warn(_('(unable to load Windows CA certificates; see '
+ 'https://mercurial-scm.org/wiki/SecureConnections for '
+ 'how to configure Mercurial to avoid this message)\n'))
+
+ return None
+
# Apple's OpenSSL has patches that allow a specially constructed certificate
# to load the system CA store. If we're running on Apple Python, use this
# trick.
if _plainapplepython():
dummycert = os.path.join(os.path.dirname(__file__), 'dummycert.pem')
if os.path.exists(dummycert):
return dummycert
@@ -55,16 +55,23 @@ we are able to load CA certs.
#endif
#if no-sslcontext defaultcacerts
$ hg clone https://localhost:$HGPORT/ copy-pull
abort: error: *certificate verify failed* (glob)
[255]
#endif
+#if no-sslcontext windows
+ $ hg clone https://localhost:$HGPORT/ copy-pull
+ (unable to load Windows CA certificates; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this message)
+ abort: error: *certificate verify failed* (glob)
+ [255]
+#endif
+
#if defaultcacertsloaded
$ hg clone https://localhost:$HGPORT/ copy-pull
abort: error: *certificate verify failed* (glob)
[255]
#endif
#if no-defaultcacerts
$ hg clone https://localhost:$HGPORT/ copy-pull