diff options
author | Dan Gudmundsson <[email protected]> | 2010-02-17 15:49:22 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-02-17 16:55:20 +0100 |
commit | f29538e8002cf0e37fa4f988fbf5484c46513bf4 (patch) | |
tree | 494a29d8a00cd872194ea3f2128a3364aa732866 /lib/ssl/test/ssl_basic_SUITE.erl | |
parent | 8b39d0582bee5d4071b7ae4c7407d6662c0414a9 (diff) | |
download | otp-f29538e8002cf0e37fa4f988fbf5484c46513bf4.tar.gz otp-f29538e8002cf0e37fa4f988fbf5484c46513bf4.tar.bz2 otp-f29538e8002cf0e37fa4f988fbf5484c46513bf4.zip |
OTP-8459 Do a controlled shutdown if a non ssl packet arrives as the first
packet.
Diffstat (limited to 'lib/ssl/test/ssl_basic_SUITE.erl')
-rw-r--r-- | lib/ssl/test/ssl_basic_SUITE.erl | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/lib/ssl/test/ssl_basic_SUITE.erl b/lib/ssl/test/ssl_basic_SUITE.erl index 22a0fb1ee1..3d9cec43dd 100644 --- a/lib/ssl/test/ssl_basic_SUITE.erl +++ b/lib/ssl/test/ssl_basic_SUITE.erl @@ -150,8 +150,8 @@ all(doc) -> all(suite) -> [app, connection_info, controlling_process, controller_dies, peercert, connect_dist, - peername, sockname, socket_options, versions, cipher_suites, upgrade, - upgrade_with_timeout, + peername, sockname, socket_options, versions, cipher_suites, + upgrade, upgrade_with_timeout, tcp_connect, ipv6, ekeyfile, ecertfile, ecacertfile, eoptions, shutdown, shutdown_write, shutdown_both, shutdown_error, ciphers, send_close, @@ -754,6 +754,45 @@ upgrade_with_timeout(Config) when is_list(Config) -> ssl_test_lib:close(Server), ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +tcp_connect(doc) -> + ["Test what happens when a tcp tries to connect, i,e. a bad (ssl) packet is sent first"]; + +tcp_connect(suite) -> + []; + +tcp_connect(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + TcpOpts = [binary, {reuseaddr, true}], + + Server = ssl_test_lib:start_upgrade_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {timeout, 5000}, + {mfa, {?MODULE, should_close, []}}, + {tcp_options, TcpOpts}, + {ssl_options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + + {ok, Socket} = gen_tcp:connect(Hostname, Port, [binary, {packet, 0}]), + test_server:format("Testcase ~p connected to Server ~p ~n", [self(), Server]), + gen_tcp:send(Socket, "<SOME GARBLED NON SSL MESSAGE>"), + + ssl_test_lib:check_result(Server, {error,esslerrssl}, tcp_closed, Socket), + + ssl_test_lib:close(Server). + + +should_close(Socket) -> + receive + {ssl, Socket, closed} -> + server_closed; + Other -> + exit({?LINE, Other}) + end. + %%-------------------------------------------------------------------- ipv6(doc) -> ["Test ipv6."]; |