Comments
Patch
@@ -1015,20 +1015,28 @@ The following options control default be
can significantly lower connection security or decrease performance.
You have been warned.
This option requires Python 2.7.
``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
per-host basis.
The following per-host settings can be defined.
``ciphers``
@@ -155,19 +155,27 @@ def _hostsettings(ui, hostname):
def validateprotocol(protocol, key):
if protocol not in configprotocols:
raise error.Abort(
_('unsupported protocol from hostsecurity.%s: %s') %
(key, protocol),
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
protocol = ui.config('hostsecurity', key, protocol)
validateprotocol(protocol, key)
s['protocol'], s['ctxoptions'] = protocolsettings(protocol)
@@ -398,16 +398,21 @@ Clients talking same TLS versions work
5fed3813f7f5
$ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.1 id https://localhost:$HGPORT1/
5fed3813f7f5
$ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.2 id https://localhost:$HGPORT2/
5fed3813f7f5
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)
[255]
$ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.2 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]