4
%% Copyright Ericsson AB 2003-2010. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
21
-module(old_ssl_peer_cert_SUITE).
33
-import(ssl_test_MACHINE, [mk_ssl_cert_opts/1, test_one_listener/7,
35
-include("test_server.hrl").
36
-include("ssl_test_MACHINE.hrl").
39
init_per_testcase(_Case, Config) ->
40
WatchDog = ssl_test_lib:timetrap(?DEFAULT_TIMEOUT),
41
[{watchdog, WatchDog}| Config].
43
fin_per_testcase(_Case, Config) ->
44
WatchDog = ?config(watchdog, Config),
45
test_server:timetrap_cancel(WatchDog).
48
"Test of ssl verification and peer certificate retrieval.";
58
"Want to se what Config contains.";
62
io:format("Config: ~p~n", [Config]),
64
%% Check if SSL exists. If this case fails, all other cases are skipped
66
application:start(public_key),
69
{error, {already_started, _}} -> ssl:stop();
70
Error -> ?t:fail({failed_starting_ssl,Error})
75
"This test case has no mission other than closing the conf case";
82
"Server closes after accept, Client waits for close. Both have certs "
83
"but both use the defaults for verify and depth, but still tries "
84
"to retreive each others certificates.";
87
cinit_plain(Config) when list(Config) ->
88
process_flag(trap_exit, true),
89
DataSize = 1000, LPort = 3456,
90
Timeout = 40000, NConns = 1,
92
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
94
?line {ok, Host} = inet:gethostname(),
96
LCmds = [{sockopts, [{backlog, NConns}]},
101
ACmds = [{timeout, Timeout},
106
CCmds = [{timeout, Timeout},
108
{connect, {Host, LPort}},
112
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout,
115
cinit_both_verify(doc) ->
116
"Server closes after accept, Client waits for close. Both have certs "
117
"and both verify each other.";
118
cinit_both_verify(suite) ->
120
cinit_both_verify(Config) when list(Config) ->
121
process_flag(trap_exit, true),
122
DataSize = 1000, LPort = 3456,
123
Timeout = 40000, NConns = 1,
125
?line {ok, {CsslOpts0, SsslOpts0}} = mk_ssl_cert_opts(Config),
126
?line CsslOpts = [{verify, 2}, {depth, 2} | CsslOpts0],
127
?line SsslOpts = [{verify, 2}, {depth, 3} | SsslOpts0],
129
?line {ok, Host} = inet:gethostname(),
131
LCmds = [{sockopts, [{backlog, NConns}]},
136
ACmds = [{timeout, Timeout},
141
CCmds = [{timeout, Timeout},
143
{connect, {Host, LPort}},
147
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout,
150
cinit_cnocert(doc) ->
151
"Client has no cert. Nor the client, nor the server is verifying its "
152
"peer. Server closes, client waits for close.";
153
cinit_cnocert(suite) ->
155
cinit_cnocert(Config) when list(Config) ->
156
process_flag(trap_exit, true),
157
DataSize = 1000, LPort = 3457,
158
Timeout = 40000, NConns = 1,
160
?line {ok, {_, SsslOpts0}} = mk_ssl_cert_opts(Config),
161
?line SsslOpts = [{verify, 0}, {depth, 2} | SsslOpts0],
163
?line {ok, Host} = inet:gethostname(),
165
LCmds = [{sockopts, [{backlog, NConns}]},
170
ACmds = [{timeout, Timeout},
174
CCmds = [{timeout, Timeout},
175
{connect, {Host, LPort}},
179
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout,