blob: 51e2e0b7943f1f3f8cf7a830e9ff911daf8e8735 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010017
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010018O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
19O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010020
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010021TESTS=0
22FAILS=0
23
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010024MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010025FILTER='.*'
26EXCLUDE='SSLv2' # disabled by default, needs OpenSSL compiled with SSLv2
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010027
28print_usage() {
29 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010030 echo -e " -h|--help\tPrint this help."
31 echo -e " -m|--memcheck\tCheck memory leaks and errors."
32 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
33 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034}
35
36get_options() {
37 while [ $# -gt 0 ]; do
38 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010039 -f|--filter)
40 shift; FILTER=$1
41 ;;
42 -e|--exclude)
43 shift; EXCLUDE=$1
44 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045 -m|--memcheck)
46 MEMCHECK=1
47 ;;
48 -h|--help)
49 print_usage
50 exit 0
51 ;;
52 *)
53 echo "Unkown argument: '$1'"
54 print_usage
55 exit 1
56 ;;
57 esac
58 shift
59 done
60}
61
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010062# print_name <name>
63print_name() {
64 echo -n "$1 "
65 LEN=`echo "$1" | wc -c`
66 LEN=`echo 72 - $LEN | bc`
67 for i in `seq 1 $LEN`; do echo -n '.'; done
68 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010069
70 TESTS=`echo $TESTS + 1 | bc`
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010071}
72
73# fail <message>
74fail() {
75 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +010076 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010077
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +010078 cp srv_out o-srv-${TESTS}.log
79 cp cli_out o-cli-${TESTS}.log
80 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010081
82 FAILS=`echo $FAILS + 1 | bc`
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010083}
84
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +010085# is_polar <cmd_line>
86is_polar() {
87 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
88}
89
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010090# has_mem_err <log_file_name>
91has_mem_err() {
92 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
93 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
94 then
95 return 1 # false: does not have errors
96 else
97 return 0 # true: has errors
98 fi
99}
100
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100101# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100102# Options: -s pattern pattern that must be present in server output
103# -c pattern pattern that must be present in client output
104# -S pattern pattern that must be absent in server output
105# -C pattern pattern that must be absent in client output
106run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100107 NAME="$1"
108 SRV_CMD="$2"
109 CLI_CMD="$3"
110 CLI_EXPECT="$4"
111 shift 4
112
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100113 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
114 else
115 return
116 fi
117
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100118 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100119
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100120 # prepend valgrind to our commands if active
121 if [ "$MEMCHECK" -gt 0 ]; then
122 if is_polar "$SRV_CMD"; then
123 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
124 fi
125 if is_polar "$CLI_CMD"; then
126 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
127 fi
128 fi
129
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100130 # run the commands
Manuel Pégourié-Gonnardba0b8442014-03-13 17:57:45 +0100131 echo "$SRV_CMD" > srv_out
132 $SHELL -c "$SRV_CMD" >> srv_out 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100133 SRV_PID=$!
134 sleep 1
Manuel Pégourié-Gonnardba0b8442014-03-13 17:57:45 +0100135 echo "$CLI_CMD" > cli_out
136 $SHELL -c "$CLI_CMD" >> cli_out 2>&1
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100137 CLI_EXIT=$?
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100138 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnard84fd6872014-03-13 18:35:10 +0100139 "$P_CLI" request_page=SERVERQUIT tickets=0 auth_mode=none \
140 crt_file=data_files/cli2.crt key_file=data_files/cli2.key \
141 >/dev/null
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100142 else
143 kill $SRV_PID
144 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100145 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100146
147 # check if the client and server went at least to the handshake stage
148 # (usefull to avoid tests with only negative assertions and non-zero
149 # expected client exit to incorrectly succeed in case of catastrophic
150 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100151 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100152 if grep "Performing the SSL/TLS handshake" srv_out >/dev/null; then :;
153 else
154 fail "server failed to start"
155 return
156 fi
157 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100158 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100159 if grep "Performing the SSL/TLS handshake" cli_out >/dev/null; then :;
160 else
161 fail "client failed to start"
162 return
163 fi
164 fi
165
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100166 # check server exit code
167 if [ $? != 0 ]; then
168 fail "server fail"
169 return
170 fi
171
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100172 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100173 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
174 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100175 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100176 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100177 return
178 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100179
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100180 # check other assertions
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100181 while [ $# -gt 0 ]
182 do
183 case $1 in
184 "-s")
185 if grep "$2" srv_out >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100186 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100187 return
188 fi
189 ;;
190
191 "-c")
192 if grep "$2" cli_out >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100193 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100194 return
195 fi
196 ;;
197
198 "-S")
199 if grep "$2" srv_out >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100200 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100201 return
202 fi
203 ;;
204
205 "-C")
206 if grep "$2" cli_out >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100207 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100208 return
209 fi
210 ;;
211
212 *)
213 echo "Unkown test: $1" >&2
214 exit 1
215 esac
216 shift 2
217 done
218
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100219 # check valgrind's results
220 if [ "$MEMCHECK" -gt 0 ]; then
221 if is_polar "$SRV_CMD" && has_mem_err srv_out; then
222 fail "Server has memory errors"
223 return
224 fi
225 if is_polar "$CLI_CMD" && has_mem_err cli_out; then
226 fail "Client has memory errors"
227 return
228 fi
229 fi
230
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100231 # if we're here, everything is ok
232 echo "PASS"
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100233 rm -f srv_out cli_out
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100234}
235
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100236cleanup() {
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100237 rm -f cli_out srv_out sess
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100238 kill $SRV_PID
239 exit 1
240}
241
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100242#
243# MAIN
244#
245
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100246# sanity checks, avoid an avalanche of errors
247if [ ! -x "$P_SRV" ]; then
248 echo "Command '$P_SRV' is not an executable file"
249 exit 1
250fi
251if [ ! -x "$P_CLI" ]; then
252 echo "Command '$P_CLI' is not an executable file"
253 exit 1
254fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100255if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
256 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100257 exit 1
258fi
259
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100260get_options "$@"
261
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100262killall -q openssl ssl_server ssl_server2
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100263trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100264
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100265# Test for SSLv2 ClientHello
266
267run_test "SSLv2 ClientHello #0 (reference)" \
268 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100269 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100270 0 \
271 -S "parse client hello v2" \
272 -S "ssl_handshake returned"
273
274# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
275run_test "SSLv2 ClientHello #1 (actual test)" \
276 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100277 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100278 0 \
279 -s "parse client hello v2" \
280 -S "ssl_handshake returned"
281
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100282# Tests for Truncated HMAC extension
283
284run_test "Truncated HMAC #0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100285 "$P_SRV debug_level=5" \
286 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100287 0 \
288 -s "dumping 'computed mac' (20 bytes)"
289
290run_test "Truncated HMAC #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100291 "$P_SRV debug_level=5" \
292 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100293 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100294 -s "dumping 'computed mac' (10 bytes)"
295
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100296# Tests for Session Tickets
297
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100298run_test "Session resume using tickets #1 (basic)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100299 "$P_SRV debug_level=4 tickets=1" \
300 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100301 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100302 -c "client hello, adding session ticket extension" \
303 -s "found session ticket extension" \
304 -s "server hello, adding session ticket extension" \
305 -c "found session_ticket extension" \
306 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100307 -S "session successfully restored from cache" \
308 -s "session successfully restored from ticket" \
309 -s "a session has been resumed" \
310 -c "a session has been resumed"
311
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100312run_test "Session resume using tickets #2 (cache disabled)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100313 "$P_SRV debug_level=4 tickets=1 cache_max=0" \
314 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100315 0 \
316 -c "client hello, adding session ticket extension" \
317 -s "found session ticket extension" \
318 -s "server hello, adding session ticket extension" \
319 -c "found session_ticket extension" \
320 -c "parse new session ticket" \
321 -S "session successfully restored from cache" \
322 -s "session successfully restored from ticket" \
323 -s "a session has been resumed" \
324 -c "a session has been resumed"
325
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100326run_test "Session resume using tickets #3 (timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100327 "$P_SRV debug_level=4 tickets=1 cache_max=0 ticket_timeout=1" \
328 "$P_CLI debug_level=4 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100329 0 \
330 -c "client hello, adding session ticket extension" \
331 -s "found session ticket extension" \
332 -s "server hello, adding session ticket extension" \
333 -c "found session_ticket extension" \
334 -c "parse new session ticket" \
335 -S "session successfully restored from cache" \
336 -S "session successfully restored from ticket" \
337 -S "a session has been resumed" \
338 -C "a session has been resumed"
339
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100340run_test "Session resume using tickets #4 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100341 "$O_SRV" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100342 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
343 0 \
344 -c "client hello, adding session ticket extension" \
345 -c "found session_ticket extension" \
346 -c "parse new session ticket" \
347 -c "a session has been resumed"
348
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100349run_test "Session resume using tickets #5 (openssl client)" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100350 "$P_SRV debug_level=4 tickets=1" \
351 "($O_CLI -sess_out sess; $O_CLI -sess_in sess; rm -f sess)" \
352 0 \
353 -s "found session ticket extension" \
354 -s "server hello, adding session ticket extension" \
355 -S "session successfully restored from cache" \
356 -s "session successfully restored from ticket" \
357 -s "a session has been resumed"
358
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100359# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100360
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100361run_test "Session resume using cache #1 (tickets enabled on client)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100362 "$P_SRV debug_level=4 tickets=0" \
363 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100364 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100365 -c "client hello, adding session ticket extension" \
366 -s "found session ticket extension" \
367 -S "server hello, adding session ticket extension" \
368 -C "found session_ticket extension" \
369 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100370 -s "session successfully restored from cache" \
371 -S "session successfully restored from ticket" \
372 -s "a session has been resumed" \
373 -c "a session has been resumed"
374
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100375run_test "Session resume using cache #2 (tickets enabled on server)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100376 "$P_SRV debug_level=4 tickets=1" \
377 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100378 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100379 -C "client hello, adding session ticket extension" \
380 -S "found session ticket extension" \
381 -S "server hello, adding session ticket extension" \
382 -C "found session_ticket extension" \
383 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100384 -s "session successfully restored from cache" \
385 -S "session successfully restored from ticket" \
386 -s "a session has been resumed" \
387 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100388
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100389run_test "Session resume using cache #3 (cache_max=0)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100390 "$P_SRV debug_level=4 tickets=0 cache_max=0" \
391 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100392 0 \
393 -S "session successfully restored from cache" \
394 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100395 -S "a session has been resumed" \
396 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100397
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100398run_test "Session resume using cache #4 (cache_max=1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100399 "$P_SRV debug_level=4 tickets=0 cache_max=1" \
400 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100401 0 \
402 -s "session successfully restored from cache" \
403 -S "session successfully restored from ticket" \
404 -s "a session has been resumed" \
405 -c "a session has been resumed"
406
407run_test "Session resume using cache #5 (timemout > delay)" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100408 "$P_SRV debug_level=4 tickets=0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100409 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100410 0 \
411 -s "session successfully restored from cache" \
412 -S "session successfully restored from ticket" \
413 -s "a session has been resumed" \
414 -c "a session has been resumed"
415
416run_test "Session resume using cache #6 (timeout < delay)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100417 "$P_SRV debug_level=4 tickets=0 cache_timeout=1" \
418 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100419 0 \
420 -S "session successfully restored from cache" \
421 -S "session successfully restored from ticket" \
422 -S "a session has been resumed" \
423 -C "a session has been resumed"
424
425run_test "Session resume using cache #7 (no timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100426 "$P_SRV debug_level=4 tickets=0 cache_timeout=0" \
427 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100428 0 \
429 -s "session successfully restored from cache" \
430 -S "session successfully restored from ticket" \
431 -s "a session has been resumed" \
432 -c "a session has been resumed"
433
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100434run_test "Session resume using cache #8 (openssl client)" \
435 "$P_SRV debug_level=4 tickets=0" \
436 "($O_CLI -sess_out sess; $O_CLI -sess_in sess; rm -f sess)" \
437 0 \
438 -s "found session ticket extension" \
439 -S "server hello, adding session ticket extension" \
440 -s "session successfully restored from cache" \
441 -S "session successfully restored from ticket" \
442 -s "a session has been resumed"
443
444run_test "Session resume using cache #9 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100445 "$O_SRV" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100446 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
447 0 \
448 -C "found session_ticket extension" \
449 -C "parse new session ticket" \
450 -c "a session has been resumed"
451
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100452# Tests for Max Fragment Length extension
453
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100454run_test "Max fragment length #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100455 "$P_SRV debug_level=4" \
456 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100457 0 \
458 -C "client hello, adding max_fragment_length extension" \
459 -S "found max fragment length extension" \
460 -S "server hello, max_fragment_length extension" \
461 -C "found max_fragment_length extension"
462
463run_test "Max fragment length #2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100464 "$P_SRV debug_level=4" \
465 "$P_CLI debug_level=4 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100466 0 \
467 -c "client hello, adding max_fragment_length extension" \
468 -s "found max fragment length extension" \
469 -s "server hello, max_fragment_length extension" \
470 -c "found max_fragment_length extension"
471
472run_test "Max fragment length #3" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100473 "$P_SRV debug_level=4 max_frag_len=4096" \
474 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100475 0 \
476 -C "client hello, adding max_fragment_length extension" \
477 -S "found max fragment length extension" \
478 -S "server hello, max_fragment_length extension" \
479 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100480
481# Tests for renegotiation
482
483run_test "Renegotiation #0 (none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100484 "$P_SRV debug_level=4" \
485 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100486 0 \
487 -C "client hello, adding renegotiation extension" \
488 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
489 -S "found renegotiation extension" \
490 -s "server hello, secure renegotiation extension" \
491 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100492 -C "=> renegotiate" \
493 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100494 -S "write hello request"
495
496run_test "Renegotiation #1 (enabled, client-initiated)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100497 "$P_SRV debug_level=4" \
498 "$P_CLI debug_level=4 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100499 0 \
500 -c "client hello, adding renegotiation extension" \
501 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
502 -s "found renegotiation extension" \
503 -s "server hello, secure renegotiation extension" \
504 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100505 -c "=> renegotiate" \
506 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100507 -S "write hello request"
508
509run_test "Renegotiation #2 (enabled, server-initiated)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100510 "$P_SRV debug_level=4 renegotiate=1" \
511 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100512 0 \
513 -c "client hello, adding renegotiation extension" \
514 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
515 -s "found renegotiation extension" \
516 -s "server hello, secure renegotiation extension" \
517 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100518 -c "=> renegotiate" \
519 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100520 -s "write hello request"
521
522run_test "Renegotiation #3 (enabled, double)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100523 "$P_SRV debug_level=4 renegotiate=1" \
524 "$P_CLI debug_level=4 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100525 0 \
526 -c "client hello, adding renegotiation extension" \
527 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
528 -s "found renegotiation extension" \
529 -s "server hello, secure renegotiation extension" \
530 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100531 -c "=> renegotiate" \
532 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100533 -s "write hello request"
534
535run_test "Renegotiation #4 (client-initiated, server-rejected)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100536 "$P_SRV debug_level=4 renegotiation=0" \
537 "$P_CLI debug_level=4 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100538 1 \
539 -c "client hello, adding renegotiation extension" \
540 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
541 -S "found renegotiation extension" \
542 -s "server hello, secure renegotiation extension" \
543 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100544 -c "=> renegotiate" \
545 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100546 -S "write hello request"
547
548run_test "Renegotiation #5 (server-initiated, client-rejected)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100549 "$P_SRV debug_level=4 renegotiate=1" \
550 "$P_CLI debug_level=4 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100551 0 \
552 -C "client hello, adding renegotiation extension" \
553 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
554 -S "found renegotiation extension" \
555 -s "server hello, secure renegotiation extension" \
556 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100557 -C "=> renegotiate" \
558 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100559 -s "write hello request" \
560 -s "SSL - An unexpected message was received from our peer" \
561 -s "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100562
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100563# Tests for auth_mode
564
565run_test "Authentication #1 (server badcert, client required)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100566 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100567 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100568 "$P_CLI debug_level=2 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100569 1 \
570 -c "x509_verify_cert() returned" \
571 -c "! self-signed or not signed by a trusted CA" \
572 -c "! ssl_handshake returned" \
573 -c "X509 - Certificate verification failed"
574
575run_test "Authentication #2 (server badcert, client optional)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100576 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100577 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100578 "$P_CLI debug_level=2 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100579 0 \
580 -c "x509_verify_cert() returned" \
581 -c "! self-signed or not signed by a trusted CA" \
582 -C "! ssl_handshake returned" \
583 -C "X509 - Certificate verification failed"
584
585run_test "Authentication #3 (server badcert, client none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100586 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100587 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100588 "$P_CLI debug_level=2 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100589 0 \
590 -C "x509_verify_cert() returned" \
591 -C "! self-signed or not signed by a trusted CA" \
592 -C "! ssl_handshake returned" \
593 -C "X509 - Certificate verification failed"
594
595run_test "Authentication #4 (client badcert, server required)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100596 "$P_SRV debug_level=4 auth_mode=required" \
597 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100598 key_file=data_files/server5.key" \
599 1 \
600 -S "skip write certificate request" \
601 -C "skip parse certificate request" \
602 -c "got a certificate request" \
603 -C "skip write certificate" \
604 -C "skip write certificate verify" \
605 -S "skip parse certificate verify" \
606 -s "x509_verify_cert() returned" \
607 -S "! self-signed or not signed by a trusted CA" \
608 -s "! ssl_handshake returned" \
609 -c "! ssl_handshake returned" \
610 -s "X509 - Certificate verification failed"
611
612run_test "Authentication #5 (client badcert, server optional)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100613 "$P_SRV debug_level=4 auth_mode=optional" \
614 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100615 key_file=data_files/server5.key" \
616 0 \
617 -S "skip write certificate request" \
618 -C "skip parse certificate request" \
619 -c "got a certificate request" \
620 -C "skip write certificate" \
621 -C "skip write certificate verify" \
622 -S "skip parse certificate verify" \
623 -s "x509_verify_cert() returned" \
624 -s "! self-signed or not signed by a trusted CA" \
625 -S "! ssl_handshake returned" \
626 -C "! ssl_handshake returned" \
627 -S "X509 - Certificate verification failed"
628
629run_test "Authentication #6 (client badcert, server none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100630 "$P_SRV debug_level=4 auth_mode=none" \
631 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100632 key_file=data_files/server5.key" \
633 0 \
634 -s "skip write certificate request" \
635 -C "skip parse certificate request" \
636 -c "got no certificate request" \
637 -c "skip write certificate" \
638 -c "skip write certificate verify" \
639 -s "skip parse certificate verify" \
640 -S "x509_verify_cert() returned" \
641 -S "! self-signed or not signed by a trusted CA" \
642 -S "! ssl_handshake returned" \
643 -C "! ssl_handshake returned" \
644 -S "X509 - Certificate verification failed"
645
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100646run_test "Authentication #7 (client no cert, server optional)" \
647 "$P_SRV debug_level=4 auth_mode=optional" \
648 "$P_CLI debug_level=4 crt_file=none key_file=none" \
649 0 \
650 -S "skip write certificate request" \
651 -C "skip parse certificate request" \
652 -c "got a certificate request" \
653 -C "skip write certificate$" \
654 -C "got no certificate to send" \
655 -S "SSLv3 client has no certificate" \
656 -c "skip write certificate verify" \
657 -s "skip parse certificate verify" \
658 -s "! no client certificate sent" \
659 -S "! ssl_handshake returned" \
660 -C "! ssl_handshake returned" \
661 -S "X509 - Certificate verification failed"
662
663run_test "Authentication #8 (openssl client no cert, server optional)" \
664 "$P_SRV debug_level=4 auth_mode=optional" \
665 "$O_CLI" \
666 0 \
667 -S "skip write certificate request" \
668 -s "skip parse certificate verify" \
669 -s "! no client certificate sent" \
670 -S "! ssl_handshake returned" \
671 -S "X509 - Certificate verification failed"
672
673run_test "Authentication #9 (client no cert, openssl server optional)" \
674 "$O_SRV -verify 10" \
675 "$P_CLI debug_level=4 crt_file=none key_file=none" \
676 0 \
677 -C "skip parse certificate request" \
678 -c "got a certificate request" \
679 -C "skip write certificate$" \
680 -c "skip write certificate verify" \
681 -C "! ssl_handshake returned"
682
683run_test "Authentication #10 (client no cert, ssl3)" \
684 "$P_SRV debug_level=4 auth_mode=optional force_version=ssl3" \
685 "$P_CLI debug_level=4 crt_file=none key_file=none" \
686 0 \
687 -S "skip write certificate request" \
688 -C "skip parse certificate request" \
689 -c "got a certificate request" \
690 -C "skip write certificate$" \
691 -c "skip write certificate verify" \
692 -c "got no certificate to send" \
693 -s "SSLv3 client has no certificate" \
694 -s "skip parse certificate verify" \
695 -s "! no client certificate sent" \
696 -S "! ssl_handshake returned" \
697 -C "! ssl_handshake returned" \
698 -S "X509 - Certificate verification failed"
699
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100700# tests for SNI
701
702run_test "SNI #0 (no SNI callback)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100703 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100704 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100705 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100706 server_name=localhost" \
707 0 \
708 -S "parse ServerName extension" \
709 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
710 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
711
712run_test "SNI #1 (matching cert 1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100713 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100714 crt_file=data_files/server5.crt key_file=data_files/server5.key \
715 sni='localhost,data_files/server2.crt,data_files/server2.key,PolarSSL Server 1,data_files/server1.crt,data_files/server1.key'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100716 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100717 server_name=localhost" \
718 0 \
719 -s "parse ServerName extension" \
720 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
721 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
722
723run_test "SNI #2 (matching cert 2)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100724 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100725 crt_file=data_files/server5.crt key_file=data_files/server5.key \
726 sni='localhost,data_files/server2.crt,data_files/server2.key,PolarSSL Server 1,data_files/server1.crt,data_files/server1.key'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100727 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100728 server_name='PolarSSL Server 1'" \
729 0 \
730 -s "parse ServerName extension" \
731 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
732 -c "subject name *: C=NL, O=PolarSSL, CN=PolarSSL Server 1"
733
734run_test "SNI #3 (no matching cert)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100735 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100736 crt_file=data_files/server5.crt key_file=data_files/server5.key \
737 sni='localhost,data_files/server2.crt,data_files/server2.key,PolarSSL Server 1,data_files/server1.crt,data_files/server1.key'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100738 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100739 server_name='PolarSSL Server 2'" \
740 1 \
741 -s "parse ServerName extension" \
742 -s "ssl_sni_wrapper() returned" \
743 -s "ssl_handshake returned" \
744 -c "ssl_handshake returned" \
745 -c "SSL - A fatal alert message was received from our peer"
746
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +0100747# Tests for non-blocking I/O: exercise a variety of handshake flows
748
749run_test "Non-blocking I/O #1 (basic handshake)" \
750 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
751 "$P_CLI nbio=2 tickets=0" \
752 0 \
753 -S "ssl_handshake returned" \
754 -C "ssl_handshake returned" \
755 -c "Read from server: .* bytes read"
756
757run_test "Non-blocking I/O #2 (client auth)" \
758 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
759 "$P_CLI nbio=2 tickets=0" \
760 0 \
761 -S "ssl_handshake returned" \
762 -C "ssl_handshake returned" \
763 -c "Read from server: .* bytes read"
764
765run_test "Non-blocking I/O #3 (ticket)" \
766 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
767 "$P_CLI nbio=2 tickets=1" \
768 0 \
769 -S "ssl_handshake returned" \
770 -C "ssl_handshake returned" \
771 -c "Read from server: .* bytes read"
772
773run_test "Non-blocking I/O #4 (ticket + client auth)" \
774 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
775 "$P_CLI nbio=2 tickets=1" \
776 0 \
777 -S "ssl_handshake returned" \
778 -C "ssl_handshake returned" \
779 -c "Read from server: .* bytes read"
780
781run_test "Non-blocking I/O #5 (ticket + client auth + resume)" \
782 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
783 "$P_CLI nbio=2 tickets=1 reconnect=1" \
784 0 \
785 -S "ssl_handshake returned" \
786 -C "ssl_handshake returned" \
787 -c "Read from server: .* bytes read"
788
789run_test "Non-blocking I/O #6 (ticket + resume)" \
790 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
791 "$P_CLI nbio=2 tickets=1 reconnect=1" \
792 0 \
793 -S "ssl_handshake returned" \
794 -C "ssl_handshake returned" \
795 -c "Read from server: .* bytes read"
796
797run_test "Non-blocking I/O #7 (session-id resume)" \
798 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
799 "$P_CLI nbio=2 tickets=0 reconnect=1" \
800 0 \
801 -S "ssl_handshake returned" \
802 -C "ssl_handshake returned" \
803 -c "Read from server: .* bytes read"
804
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100805run_test "Version check #1 (all -> 1.2)" \
806 "$P_SRV" \
807 "$P_CLI" \
808 0 \
809 -S "ssl_handshake returned" \
810 -C "ssl_handshake returned" \
811 -s "Protocol is TLSv1.2" \
812 -c "Protocol is TLSv1.2"
813
814run_test "Version check #2 (cli max 1.1 -> 1.1)" \
815 "$P_SRV" \
816 "$P_CLI max_version=tls1_1" \
817 0 \
818 -S "ssl_handshake returned" \
819 -C "ssl_handshake returned" \
820 -s "Protocol is TLSv1.1" \
821 -c "Protocol is TLSv1.1"
822
823run_test "Version check #3 (srv max 1.1 -> 1.1)" \
824 "$P_SRV max_version=tls1_1" \
825 "$P_CLI" \
826 0 \
827 -S "ssl_handshake returned" \
828 -C "ssl_handshake returned" \
829 -s "Protocol is TLSv1.1" \
830 -c "Protocol is TLSv1.1"
831
832run_test "Version check #4 (cli+srv max 1.1 -> 1.1)" \
833 "$P_SRV max_version=tls1_1" \
834 "$P_CLI max_version=tls1_1" \
835 0 \
836 -S "ssl_handshake returned" \
837 -C "ssl_handshake returned" \
838 -s "Protocol is TLSv1.1" \
839 -c "Protocol is TLSv1.1"
840
841run_test "Version check #5 (cli max 1.1, srv min 1.1 -> 1.1)" \
842 "$P_SRV min_version=tls1_1" \
843 "$P_CLI max_version=tls1_1" \
844 0 \
845 -S "ssl_handshake returned" \
846 -C "ssl_handshake returned" \
847 -s "Protocol is TLSv1.1" \
848 -c "Protocol is TLSv1.1"
849
850run_test "Version check #6 (cli min 1.1, srv max 1.1 -> 1.1)" \
851 "$P_SRV max_version=tls1_1" \
852 "$P_CLI min_version=tls1_1" \
853 0 \
854 -S "ssl_handshake returned" \
855 -C "ssl_handshake returned" \
856 -s "Protocol is TLSv1.1" \
857 -c "Protocol is TLSv1.1"
858
859run_test "Version check #7 (cli min 1.2, srv max 1.1 -> fail)" \
860 "$P_SRV max_version=tls1_1" \
861 "$P_CLI min_version=tls1_2" \
862 1 \
863 -s "ssl_handshake returned" \
864 -c "ssl_handshake returned" \
865 -c "SSL - Handshake protocol not within min/max boundaries"
866
867run_test "Version check #8 (srv min 1.2, cli max 1.1 -> fail)" \
868 "$P_SRV min_version=tls1_2" \
869 "$P_CLI max_version=tls1_1" \
870 1 \
871 -s "ssl_handshake returned" \
872 -c "ssl_handshake returned" \
873 -s "SSL - Handshake protocol not within min/max boundaries"
874
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100875# Final report
876
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100877echo "------------------------------------------------------------------------"
878
879if [ $FAILS = 0 ]; then
880 echo -n "PASSED"
881else
882 echo -n "FAILED"
883fi
884PASSES=`echo $TESTS - $FAILS | bc`
Manuel Pégourié-Gonnard4145b892014-02-24 13:20:14 +0100885echo " ($PASSES / $TESTS tests)"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100886
887exit $FAILS