aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Uhlig <[email protected]>2024-11-07 08:23:52 +0100
committerLoïc Hoguin <[email protected]>2024-11-12 14:56:28 +0100
commite5649ba630c5be25a0c9c9f20c78f8f9f72e363e (patch)
treec124fab6ef12a05d301269d984f30bc42eb68a46
parentb0f008d64cde4593d881aba7b4eb90a875919a46 (diff)
downloadranch-e5649ba630c5be25a0c9c9f20c78f8f9f72e363e.tar.gz
ranch-e5649ba630c5be25a0c9c9f20c78f8f9f72e363e.tar.bz2
ranch-e5649ba630c5be25a0c9c9f20c78f8f9f72e363e.zip
Test for extended handshake error reason
-rw-r--r--test/acceptor_SUITE.erl27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/acceptor_SUITE.erl b/test/acceptor_SUITE.erl
index 7144612..9bf4ffc 100644
--- a/test/acceptor_SUITE.erl
+++ b/test/acceptor_SUITE.erl
@@ -85,6 +85,7 @@ groups() ->
ssl_local_echo,
ssl_graceful,
ssl_handshake,
+ ssl_handshake_error,
ssl_sni_echo,
ssl_sni_fail,
ssl_tls_psk,
@@ -850,6 +851,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 ->