Comments
Patch
@@ -259,17 +259,23 @@ def wrapsocket(sock, keyfile, certfile,
server (and client) support SNI, this tells the server which certificate
to use.
"""
if not serverhostname:
raise error.Abort(_('serverhostname argument is required'))
settings = _hostsettings(ui, serverhostname)
- # TODO use ssl.create_default_context() on modernssl.
+ # We can't use ssl.create_default_context() because it calls
+ # load_default_certs() unless CA arguments are passed to it. We want to
+ # have explicit control over CA loading because implicitly loading
+ # CAs may undermine the user's intent. For example, a user may define a CA
+ # bundle with a specific CA cert removed. If the system/default CA bundle
+ # is loaded and contains that removed CA, you've just undone the user's
+ # choice.
sslcontext = SSLContext(settings['protocol'])
# This is a no-op unless using modern ssl.
sslcontext.options |= settings['ctxoptions']
# This still works on our fake SSLContext.
sslcontext.verify_mode = settings['verifymode']