Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
  • Loading branch information
IngelaAndin committed Oct 25, 2024
2 parents 0b6fe48 + 79d7951 commit 2c82d3c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
9 changes: 5 additions & 4 deletions lib/ssl/src/ssl_gen_statem.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1880,11 +1880,12 @@ log_alert(Level, Role, ProtocolName, StateName, Alert) ->
statename => StateName,
alert => Alert,
alerter => peer}, Alert#alert.where).
terminate_alert(normal) ->
?ALERT_REC(?WARNING, ?CLOSE_NOTIFY);
terminate_alert({Reason, _}) when Reason == close;
Reason == shutdown ->
terminate_alert(Reason) when Reason == normal;
Reason == shutdown;
Reason == close ->
?ALERT_REC(?WARNING, ?CLOSE_NOTIFY);
terminate_alert({Reason, _}) ->
terminate_alert(Reason);
terminate_alert(_) ->
?ALERT_REC(?FATAL, ?INTERNAL_ERROR).

Expand Down
7 changes: 5 additions & 2 deletions lib/ssl/test/ssl_trace_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,12 @@ tc_api_profile(Config) ->
check_trace_map(Ref, TracesAfterConnect, UnhandledTraceCnt1),
ssl_test_lib:close(Server),
ssl_test_lib:close(Client),
%% terminate_alert will get called twice by both client and
%% server to strip away Details from {shutdown::Reason, Detatils}
%% before matching the Reason
UnhandledTraceCnt2 =
#{call => 0, processed => no_trace_received, exception_from => 0,
return_from => 0},
#{call => 2, processed => no_trace_received, exception_from => 0,
return_from => 2},
check_trace_map(Ref, TracesAfterDisconnect, UnhandledTraceCnt2),
ssl_trace:stop(),
ok.
Expand Down
33 changes: 33 additions & 0 deletions lib/ssl/test/tls_api_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
tls_shutdown_both/1,
tls_shutdown_error/0,
tls_shutdown_error/1,
tls_sup_shutdown/0,
tls_sup_shutdown/1,
tls_client_closes_socket/0,
tls_client_closes_socket/1,
tls_closed_in_active_once/0,
Expand Down Expand Up @@ -164,6 +166,7 @@ api_tests() ->
tls_shutdown_write,
tls_shutdown_both,
tls_shutdown_error,
tls_sup_shutdown,
tls_password_correct,
tls_password_incorrect,
tls_password_badarg,
Expand Down Expand Up @@ -797,6 +800,36 @@ tls_tcp_error_propagation_in_active_mode(Config) when is_list(Config) ->

ssl_test_lib:check_result(Client, {ssl_closed, SslSocket}).

%%--------------------------------------------------------------------
tls_sup_shutdown() ->
[{doc,"Test that terminate behaves correctly for exit(shutdown) as done by supervisor at application shutdown"}].
tls_sup_shutdown(Config) when is_list(Config) ->
ClientOpts = ssl_test_lib:ssl_options(client_rsa_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_opts, Config),

{ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),

Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0},
{from, self()},
{mfa, {?MODULE, receive_msg, []}},
{options, ServerOpts}]),
Port = ssl_test_lib:inet_port(Server),

{_, #sslsocket{pid=[Pid|_]}} = ssl_test_lib:start_client([return_socket,
{node, ClientNode}, {port, Port},
{host, Hostname},
{from, self()},
{mfa, {ssl_test_lib, no_result, []}},
{options, [{active, false} | ClientOpts]}]),
exit(Pid, shutdown),

receive
{Server, {ssl_closed, _}} ->
ok;
Msg ->
ct:fail(Msg)
end.

%%--------------------------------------------------------------------
tls_reject_warning_alert_in_initial_hs() ->
[{doc,"Test sending warning ALERT instead of client hello"}].
Expand Down

0 comments on commit 2c82d3c

Please sign in to comment.