comparison mercurial/sslutil.py @ 29561:1a782fabf80d

sslutil: print a warning when using TLS 1.0 on legacy Python Mercurial now requires TLS 1.1+ when TLS 1.1+ is supported by the client. Since we made the decision to require TLS 1.1+ when running with modern Python versions, it makes sense to do something for legacy Python versions that only support TLS 1.0. Feature parity would be to prevent TLS 1.0 connections out of the box and require a config option to enable them. However, this is extremely user hostile since Mercurial wouldn't talk to https:// by default in these installations! I can easily see how someone would do something foolish like use "--insecure" instead - and that would be worse than allowing TLS 1.0! This patch takes the compromise position of printing a warning when performing TLS 1.0 connections when running on old Python versions. While this warning is no more annoying than the CA certificate / fingerprint warnings in Mercurial 3.8, we provide a config option to disable the warning because to many people upgrading Python to make the warning go away is not an available recourse (unlike pinning fingerprints is for the CA warning). The warning appears as optional output in a lot of tests.
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 13 Jul 2016 21:49:17 -0700
parents 303e9300772a
children 9654ef41f7cc
comparison
equal deleted inserted replaced
29560:303e9300772a 29561:1a782fabf80d
159 # We allow users to downgrade to TLS 1.0+ via config options in case a 159 # We allow users to downgrade to TLS 1.0+ via config options in case a
160 # legacy server is encountered. 160 # legacy server is encountered.
161 if modernssl: 161 if modernssl:
162 defaultprotocol = 'tls1.1' 162 defaultprotocol = 'tls1.1'
163 else: 163 else:
164 # Let people on legacy Python versions know they are borderline
165 # secure.
166 # We don't document this config option because we want people to see
167 # the bold warnings on the web site.
168 # internal config: hostsecurity.disabletls10warning
169 if not ui.configbool('hostsecurity', 'disabletls10warning'):
170 ui.warn(_('warning: connecting to %s using legacy security '
171 'technology (TLS 1.0); see '
172 'https://mercurial-scm.org/wiki/SecureConnections for '
173 'more info\n') % hostname)
164 defaultprotocol = 'tls1.0' 174 defaultprotocol = 'tls1.0'
165 175
166 key = 'minimumprotocol' 176 key = 'minimumprotocol'
167 protocol = ui.config('hostsecurity', key, defaultprotocol) 177 protocol = ui.config('hostsecurity', key, defaultprotocol)
168 validateprotocol(protocol, key) 178 validateprotocol(protocol, key)