diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt --- a/mercurial/help/config.txt +++ b/mercurial/help/config.txt @@ -1008,10 +1008,18 @@ The following options control default be ``minimumprotocol`` Defines the minimum channel encryption protocol to use. - By default, the highest version of TLS - 1.0 or greater - supported by - both client and server is used. - - Allowed values are: ``tls1.0`` (the default), ``tls1.1``, ``tls1.2``. + By default, the highest version of TLS supported by both client and server + is used. + + Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``. + + When running on an old Python version, only ``tls1.0`` is allowed since + old versions of Python only support up to TLS 1.0. + + When running a Python that supports modern TLS versions, the default is + ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this + weakens security and should only be used as a feature of last resort if + a server does not support TLS 1.1+. Options in the ``[hostsecurity]`` section can have the form ``hostname``:``setting``. This allows multiple settings to be defined on a diff --git a/mercurial/sslutil.py b/mercurial/sslutil.py --- a/mercurial/sslutil.py +++ b/mercurial/sslutil.py @@ -154,9 +154,17 @@ def _hostsettings(ui, hostname): hint=_('valid protocols: %s') % ' '.join(sorted(configprotocols))) + # Legacy Python can only do TLS 1.0. We default to TLS 1.1+ where we + # can because TLS 1.0 has known vulnerabilities (like BEAST and POODLE). + # We allow users to downgrade to TLS 1.0+ via config options in case a + # legacy server is encountered. + if modernssl: + defaultprotocol = 'tls1.1' + else: + defaultprotocol = 'tls1.0' + key = 'minimumprotocol' - # Default to TLS 1.0+ as that is what browsers are currently doing. - protocol = ui.config('hostsecurity', key, 'tls1.0') + protocol = ui.config('hostsecurity', key, defaultprotocol) validateprotocol(protocol, key) key = '%s:minimumprotocol' % hostname diff --git a/tests/test-https.t b/tests/test-https.t --- a/tests/test-https.t +++ b/tests/test-https.t @@ -377,6 +377,11 @@ Clients talking same TLS versions work Clients requiring newer TLS version than what server supports fail + $ P="$CERTSDIR" hg id https://localhost:$HGPORT/ + (could not negotiate a common protocol; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this error) + abort: error: *unsupported protocol* (glob) + [255] + $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.1 id https://localhost:$HGPORT/ (could not negotiate a common protocol; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this error) abort: error: *unsupported protocol* (glob)