-
-
Notifications
You must be signed in to change notification settings - Fork 335
strip out options unsupported in TLS1.3 before listening on socket #313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dc8ba08
4c8e58f
8aef9e6
67d26b4
40c11ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,7 +129,8 @@ do_listen(SocketOpts0, Logger) -> | |
| SocketOpts1 = ranch:set_option_default(SocketOpts0, backlog, 1024), | ||
| SocketOpts2 = ranch:set_option_default(SocketOpts1, nodelay, true), | ||
| SocketOpts3 = ranch:set_option_default(SocketOpts2, send_timeout, 30000), | ||
| SocketOpts = ranch:set_option_default(SocketOpts3, send_timeout_close, true), | ||
| SocketOpts4 = ranch:set_option_default(SocketOpts3, send_timeout_close, true), | ||
| SocketOpts = strip_unsupported_options(SocketOpts4), | ||
| %% We set the port to 0 because it is given in the Opts directly. | ||
| %% The port in the options takes precedence over the one in the | ||
| %% first argument. | ||
|
|
@@ -296,3 +297,25 @@ cleanup(#{socket_opts:=SocketOpts}) -> | |
| end; | ||
| cleanup(_) -> | ||
| ok. | ||
|
|
||
| -spec strip_unsupported_options(opts()) -> opts(). | ||
| strip_unsupported_options(SocketOpts) -> | ||
| Versions1 = lists:keyfind(versions, 1, SocketOpts), | ||
| Versions2 = lists:keyfind(protocol_versions, 1, SocketOpts), | ||
| if | ||
| (Versions1 == {versions, ['tlsv1.3']}) or (Versions2 == {protocol_versions, ['tlsv1.3']}) -> | ||
| NewSocketOpts = lists:filter(fun({X, _}) -> | ||
| (X /= secure_renegotiate) and (X /= reuse_sessions) and (X /= next_protocols_advertised) and (X /= alpn_preferred_protocols); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to do it this way (and I'm pretty sure that @essen will object 😅), you should use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to log what is dropped indeed. |
||
| (_) -> | ||
| true | ||
| end, SocketOpts), | ||
| if | ||
| NewSocketOpts /= SocketOpts -> | ||
| error_logger:warning_msg("~p~n dropping options unsupported by TLS1.3-only ssl sockets: " ++ | ||
| "secure_renegotiate, reuse_sessions, next_protocols_advertised and/or alpn_preferred_protocols from ~p~n", [?MODULE, SocketOpts]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should not use Also, the message is at the same time very verbose and doesn't tell very much, ie which options were actually dropped. |
||
| end, | ||
| NewSocketOpts; | ||
| true -> | ||
| SocketOpts | ||
| end. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protocol_versionsis not inSocketOptsbut in the environment of thesslapplicationIf
versionsis given inSocketOpts, it overridesprotocol_versionsfrom the application environment.