Skip to content

Commit 6a54781

Browse files
authored
Merge pull request #10979 from IngelaAndin/ingela/ssl/remove-unsecure-fallback/OTP-20080
Remove insecure renegotiation fallback pre TLS-1.3
2 parents 668244b + 0dd1ed2 commit 6a54781

6 files changed

Lines changed: 279 additions & 359 deletions

File tree

lib/ssl/doc/guides/ssl_distribution.md

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,6 @@ handling decoding errors and directly verifying signatures.
271271
For more details see `{verify_fun, Verify}` [in common_option_cert](`t:ssl:common_option_cert/0`)
272272

273273

274-
> #### Note {: .info }
275-
> The legacy command line format for `verify_fun` cannot be used
276-
> in a `-ssl_dist_optfile` file as described below in
277-
> [Specifying TLS Options (Legacy)](#specifying-tls-options-legacy).
278-
279274
## Using TLS distribution over IPv6
280275

281276
It is possible to use TLS distribution over IPv6 instead of IPv4. To do this,
@@ -295,99 +290,3 @@ A node started in this way will only be able to communicate with other nodes
295290
using TLS distribution over IPv6.
296291

297292

298-
## Specifying TLS Options (Legacy)
299-
300-
> #### Note {: .info }
301-
> The following section describes TLS Option handling prior to OTP 20.2
302-
> and can only handle a small subset of the actual available options.
303-
> It is here only for the sake of backwards compatibility .
304-
305-
As in the previous section the PEM file `"/home/me/ssl/erlserver.pem"` contains
306-
both the server certificate and its private key.
307-
308-
On the `erl` command line you can specify options that the TLS distribution adds
309-
when creating a socket.
310-
311-
The simplest TLS options in the following list can be specified by adding the
312-
prefix `server_` or `client_` to the option name:
313-
314-
- `certfile`
315-
- `keyfile`
316-
- `password`
317-
- `cacertfile`
318-
- `verify`
319-
- `verify_fun` (write as `{Module, Function, InitialUserState}`)
320-
- `crl_check`
321-
- `crl_cache` (write as Erlang term)
322-
- `reuse_sessions`
323-
- `secure_renegotiate`
324-
- `depth`
325-
- `hibernate_after`
326-
- `ciphers` (use old string format)
327-
328-
Note that `verify_fun` needs to be written in a different form than the
329-
corresponding TLS option, since funs are not accepted on the command line.
330-
331-
The server can also take the options `dhfile` and `fail_if_no_peer_cert` (also
332-
prefixed).
333-
334-
`client_`\-prefixed options are used when the distribution initiates a
335-
connection to another node. `server_`\-prefixed options are used when accepting
336-
a connection from a remote node.
337-
338-
Raw socket options, such as `packet` and `size` must not be specified on the
339-
command line.
340-
341-
The command-line argument for specifying the TLS options is named
342-
`-ssl_dist_opt` and is to be followed by pairs of SSL options and their values.
343-
Argument `-ssl_dist_opt` can be repeated any number of times.
344-
345-
An example command line doing the same as the example in the previous section
346-
can now look as follows (line breaks in the command are for readability, and
347-
shall not be there when typed):
348-
349-
```text
350-
$ erl -boot /home/me/ssl/start_ssl -proto_dist inet_tls
351-
-ssl_dist_opt server_certfile "/home/me/ssl/erlserver.pem"
352-
-ssl_dist_opt server_secure_renegotiate true client_secure_renegotiate true
353-
-sname ssl_test
354-
Erlang (BEAM) emulator version 5.0 [source]
355-
356-
Eshell V5.0 (abort with ^G)
357-
(ssl_test@myhost)1>
358-
```
359-
360-
### Setting up Environment to Always Use TLS
361-
362-
A convenient way to specify arguments to Erlang is to use environment variable
363-
`ERL_FLAGS`. All the flags needed to use the TLS distribution can be specified
364-
in that variable and are then interpreted as command-line arguments for all
365-
subsequent invocations of Erlang.
366-
367-
In a Unix (Bourne) shell, it can look as follows (line breaks are for
368-
readability, they are not to be there when typed):
369-
370-
```erlang
371-
$ ERL_FLAGS="-boot /home/me/ssl/start_ssl -proto_dist inet_tls
372-
-ssl_dist_opt server_certfile /home/me/ssl/erlserver.pem
373-
-ssl_dist_opt server_secure_renegotiate true client_secure_renegotiate true"
374-
$ export ERL_FLAGS
375-
$ erl -sname ssl_test
376-
Erlang (BEAM) emulator version 5.0 [source]
377-
378-
Eshell V5.0 (abort with ^G)
379-
(ssl_test@myhost)1> init:get_arguments().
380-
[{root,["/usr/local/erlang"]},
381-
{progname,["erl "]},
382-
{sname,["ssl_test"]},
383-
{boot,["/home/me/ssl/start_ssl"]},
384-
{proto_dist,["inet_tls"]},
385-
{ssl_dist_opt,["server_certfile","/home/me/ssl/erlserver.pem"]},
386-
{ssl_dist_opt,["server_secure_renegotiate","true",
387-
"client_secure_renegotiate","true"]
388-
{home,["/home/me"]}]
389-
```
390-
391-
The `init:get_arguments()` call verifies that the correct arguments are supplied
392-
to the emulator.
393-

lib/ssl/src/ssl.erl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -955,15 +955,13 @@ Options common to client and server side prior to TLS-1.3.
955955

956956
Elliptic curves that can be used in pre TLS-1.3 key exchange.
957957

958-
- **`{secure_renegotiate, SecureRenegotiate}`** - Inter-operate trade-off option
958+
- **`{secure_renegotiate, SecureRenegotiate}`** - Previous interoperability option
959959

960-
Specifies whether to reject renegotiation attempt that does not live
961-
up to [RFC 5746](http://www.ietf.org/rfc/rfc5746.txt). By default,
962-
`SecureRenegotiate` is `true`, meaning that secure renegotiation is
963-
enforced. If `SecureRenegotiate` is `false` secure renegotiation
964-
will still be used if possible, but it falls back to insecure
965-
renegotiation if the peer does not support if [RFC
966-
5746](http://www.ietf.org/rfc/rfc5746.txt).
960+
Since OTP 29.0 setting this option to false will fail, that is accepting
961+
possible fallback to insecure behavior preceding implementation of
962+
[RFC 5746](http://www.ietf.org/rfc/rfc5746.txt) is no longer supported.
963+
Setting it to true will continue to work but is not necessary, as the default
964+
of `true` will now always be enforced.
967965

968966
- **`{user_lookup_fun, {LookupFun, UserState}}`** - PSK/SRP cipher suite option
969967

@@ -990,7 +988,7 @@ Options common to client and server side prior to TLS-1.3.
990988
""".
991989

992990
-type common_option_pre_tls13() :: {eccs, NamedCurves::[named_curve()]} |
993-
{secure_renegotiate, SecureRenegotiate::boolean()} |
991+
{secure_renegotiate, SecureRenegotiate::true} |
994992
{user_lookup_fun, {Lookupfun :: fun(), UserState :: any()}}.
995993

996994
-doc(#{group =>

lib/ssl/src/ssl_config.erl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,10 +1353,12 @@ opt_renegotiate(UserOpts, #{versions := Versions} = Opts, _Env) ->
13531353
{_, RA0} = get_opt_pos_int(renegotiate_at, ?DEFAULT_RENEGOTIATE_AT, UserOpts, Opts),
13541354
RA = min(RA0, ?DEFAULT_RENEGOTIATE_AT), %% Override users choice without notifying ??
13551355

1356-
{Where3, SR} = get_opt_bool(secure_renegotiate, true, UserOpts, Opts),
1356+
{Where3, _} = disable_insecure_fallback(UserOpts, Opts),
13571357
assert_version_dep(Where3 =:= new, secure_renegotiate, Versions, ['tlsv1','tlsv1.1','tlsv1.2']),
13581358

1359-
Opts#{secure_renegotiate => SR, key_update_at => KUA, renegotiate_at => RA}.
1359+
%% Do not include secure_renegotiate as option is no longer needed,
1360+
%% that is, it is treated as always set to true
1361+
Opts#{key_update_at => KUA, renegotiate_at => RA}.
13601362

13611363
opt_reuse_sessions(UserOpts, #{versions := Versions} = Opts, #{role := client}) ->
13621364
{Where1, RUSS} = get_opt_of(reuse_sessions, [true, false, save], true, UserOpts, Opts),
@@ -1388,6 +1390,15 @@ opt_identity(UserOpts, Opts, _Env) ->
13881390
Lookup = handle_user_lookup(UserOpts, Opts),
13891391
Opts#{psk_identity => PSK, srp_identity => SRP, user_lookup_fun => Lookup}.
13901392

1393+
disable_insecure_fallback(UserOpts, Opts) ->
1394+
case get_opt_bool(secure_renegotiate, true, UserOpts, Opts) of
1395+
{_, true} = Result ->
1396+
Result;
1397+
{_, What} ->
1398+
option_error(secure_renegotiate,
1399+
{What,
1400+
fallback_to_insecure_renegotiation_no_longer_supported})
1401+
end.
13911402

13921403
handle_psk(UserOpts, #{versions := Versions} = Opts) ->
13931404
case get_opt_list(psk_identity, undefined, UserOpts, Opts) of

0 commit comments

Comments
 (0)