Skip to content

Commit

Permalink
Test for extended handshake error reason
Browse files Browse the repository at this point in the history
  • Loading branch information
juhlig committed May 17, 2024
1 parent 2521469 commit d2babd6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/acceptor_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ groups() ->
ssl_local_echo,
ssl_graceful,
ssl_handshake,
ssl_handshake_error,
ssl_sni_echo,
ssl_sni_fail,
ssl_tls_psk,
Expand Down Expand Up @@ -834,6 +835,32 @@ ssl_handshake(_) ->
{'EXIT', _} = begin catch ranch:get_port(Name) end,
ok.

ssl_handshake_error(_) ->
doc("Acceptor must not crash if client disconnects in the middle of SSL handshake."),
Name = name(),
Opts = ct_helper:get_certs_from_ets(),
{ok, _} = ranch:start_listener(Name,
ranch_ssl, #{num_acceptors => 1, socket_opts => Opts},
echo_protocol, []),
Port = ranch:get_port(Name),
{ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]),
receive after 500 -> ok end,
[ConnPid] = ranch:procs(Name, connections),
ConnMon = monitor(process, ConnPid),
ok = gen_tcp:send(Socket, <<"GARBAGE">>),
ok = gen_tcp:close(Socket),
receive
{'DOWN', ConnMon, process, ConnPid, R} ->
{shutdown, {_, _}} = R
after 1000 ->
error(timeout)
end,
receive after 500 -> ok end,
ok = ranch:stop_listener(Name),
%% Make sure the listener stopped.
{'EXIT', _} = begin catch ranch:get_port(Name) end,
ok.

ssl_local_echo(_) ->
case do_os_supports_local_sockets() of
true ->
Expand Down

0 comments on commit d2babd6

Please sign in to comment.