Comments
Patch
@@ -259,18 +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.
- sslcontext = SSLContext(settings['protocol'])
+ if modernssl:
+ assert settings['protocol'] == ssl.PROTOCOL_SSLv23
+ sslcontext = ssl.create_default_context()
+ # We have our own hostname verification code.
+ sslcontext.check_hostname = False
+ else:
+ 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']
if certfile is not None: