blob: c0645b25d36fb9b88d58ce1bec64b349c6c37a2c [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é-Gonnarde01af4c2014-03-25 14:16:44 +0100138 echo "EXIT: $CLI_EXIT" >> cli_out
139
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100140 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnard84fd6872014-03-13 18:35:10 +0100141 "$P_CLI" request_page=SERVERQUIT tickets=0 auth_mode=none \
142 crt_file=data_files/cli2.crt key_file=data_files/cli2.key \
143 >/dev/null
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100144 else
145 kill $SRV_PID
146 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100147 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100148
149 # check if the client and server went at least to the handshake stage
150 # (usefull to avoid tests with only negative assertions and non-zero
151 # expected client exit to incorrectly succeed in case of catastrophic
152 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100153 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100154 if grep "Performing the SSL/TLS handshake" srv_out >/dev/null; then :;
155 else
156 fail "server failed to start"
157 return
158 fi
159 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100160 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100161 if grep "Performing the SSL/TLS handshake" cli_out >/dev/null; then :;
162 else
163 fail "client failed to start"
164 return
165 fi
166 fi
167
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100168 # check server exit code
169 if [ $? != 0 ]; then
170 fail "server fail"
171 return
172 fi
173
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100174 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100175 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
176 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100177 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100178 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100179 return
180 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100181
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100182 # check other assertions
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100183 while [ $# -gt 0 ]
184 do
185 case $1 in
186 "-s")
187 if grep "$2" srv_out >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100188 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100189 return
190 fi
191 ;;
192
193 "-c")
194 if grep "$2" cli_out >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100195 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100196 return
197 fi
198 ;;
199
200 "-S")
201 if grep "$2" srv_out >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100202 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100203 return
204 fi
205 ;;
206
207 "-C")
208 if grep "$2" cli_out >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100209 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100210 return
211 fi
212 ;;
213
214 *)
215 echo "Unkown test: $1" >&2
216 exit 1
217 esac
218 shift 2
219 done
220
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100221 # check valgrind's results
222 if [ "$MEMCHECK" -gt 0 ]; then
223 if is_polar "$SRV_CMD" && has_mem_err srv_out; then
224 fail "Server has memory errors"
225 return
226 fi
227 if is_polar "$CLI_CMD" && has_mem_err cli_out; then
228 fail "Client has memory errors"
229 return
230 fi
231 fi
232
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100233 # if we're here, everything is ok
234 echo "PASS"
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100235 rm -f srv_out cli_out
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100236}
237
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100238cleanup() {
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100239 rm -f cli_out srv_out sess
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100240 kill $SRV_PID
241 exit 1
242}
243
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100244#
245# MAIN
246#
247
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100248# sanity checks, avoid an avalanche of errors
249if [ ! -x "$P_SRV" ]; then
250 echo "Command '$P_SRV' is not an executable file"
251 exit 1
252fi
253if [ ! -x "$P_CLI" ]; then
254 echo "Command '$P_CLI' is not an executable file"
255 exit 1
256fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100257if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
258 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100259 exit 1
260fi
261
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100262get_options "$@"
263
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100264killall -q openssl ssl_server ssl_server2
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100265trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100266
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100267# Test for SSLv2 ClientHello
268
269run_test "SSLv2 ClientHello #0 (reference)" \
270 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100271 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100272 0 \
273 -S "parse client hello v2" \
274 -S "ssl_handshake returned"
275
276# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
277run_test "SSLv2 ClientHello #1 (actual test)" \
278 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100279 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100280 0 \
281 -s "parse client hello v2" \
282 -S "ssl_handshake returned"
283
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100284# Tests for Truncated HMAC extension
285
286run_test "Truncated HMAC #0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100287 "$P_SRV debug_level=5" \
288 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100289 0 \
290 -s "dumping 'computed mac' (20 bytes)"
291
292run_test "Truncated HMAC #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100293 "$P_SRV debug_level=5" \
294 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100295 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100296 -s "dumping 'computed mac' (10 bytes)"
297
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100298# Tests for Session Tickets
299
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100300run_test "Session resume using tickets #1 (basic)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100301 "$P_SRV debug_level=4 tickets=1" \
302 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100303 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100304 -c "client hello, adding session ticket extension" \
305 -s "found session ticket extension" \
306 -s "server hello, adding session ticket extension" \
307 -c "found session_ticket extension" \
308 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100309 -S "session successfully restored from cache" \
310 -s "session successfully restored from ticket" \
311 -s "a session has been resumed" \
312 -c "a session has been resumed"
313
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100314run_test "Session resume using tickets #2 (cache disabled)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100315 "$P_SRV debug_level=4 tickets=1 cache_max=0" \
316 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100317 0 \
318 -c "client hello, adding session ticket extension" \
319 -s "found session ticket extension" \
320 -s "server hello, adding session ticket extension" \
321 -c "found session_ticket extension" \
322 -c "parse new session ticket" \
323 -S "session successfully restored from cache" \
324 -s "session successfully restored from ticket" \
325 -s "a session has been resumed" \
326 -c "a session has been resumed"
327
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100328run_test "Session resume using tickets #3 (timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100329 "$P_SRV debug_level=4 tickets=1 cache_max=0 ticket_timeout=1" \
330 "$P_CLI debug_level=4 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100331 0 \
332 -c "client hello, adding session ticket extension" \
333 -s "found session ticket extension" \
334 -s "server hello, adding session ticket extension" \
335 -c "found session_ticket extension" \
336 -c "parse new session ticket" \
337 -S "session successfully restored from cache" \
338 -S "session successfully restored from ticket" \
339 -S "a session has been resumed" \
340 -C "a session has been resumed"
341
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100342run_test "Session resume using tickets #4 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100343 "$O_SRV" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100344 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
345 0 \
346 -c "client hello, adding session ticket extension" \
347 -c "found session_ticket extension" \
348 -c "parse new session ticket" \
349 -c "a session has been resumed"
350
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100351run_test "Session resume using tickets #5 (openssl client)" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100352 "$P_SRV debug_level=4 tickets=1" \
353 "($O_CLI -sess_out sess; $O_CLI -sess_in sess; rm -f sess)" \
354 0 \
355 -s "found session ticket extension" \
356 -s "server hello, adding session ticket extension" \
357 -S "session successfully restored from cache" \
358 -s "session successfully restored from ticket" \
359 -s "a session has been resumed"
360
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100361# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100362
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100363run_test "Session resume using cache #1 (tickets enabled on client)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100364 "$P_SRV debug_level=4 tickets=0" \
365 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100366 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100367 -c "client hello, adding session ticket extension" \
368 -s "found session ticket extension" \
369 -S "server hello, adding session ticket extension" \
370 -C "found session_ticket extension" \
371 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100372 -s "session successfully restored from cache" \
373 -S "session successfully restored from ticket" \
374 -s "a session has been resumed" \
375 -c "a session has been resumed"
376
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100377run_test "Session resume using cache #2 (tickets enabled on server)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100378 "$P_SRV debug_level=4 tickets=1" \
379 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100380 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100381 -C "client hello, adding session ticket extension" \
382 -S "found session ticket extension" \
383 -S "server hello, adding session ticket extension" \
384 -C "found session_ticket extension" \
385 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100386 -s "session successfully restored from cache" \
387 -S "session successfully restored from ticket" \
388 -s "a session has been resumed" \
389 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100390
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100391run_test "Session resume using cache #3 (cache_max=0)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100392 "$P_SRV debug_level=4 tickets=0 cache_max=0" \
393 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100394 0 \
395 -S "session successfully restored from cache" \
396 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100397 -S "a session has been resumed" \
398 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100399
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100400run_test "Session resume using cache #4 (cache_max=1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100401 "$P_SRV debug_level=4 tickets=0 cache_max=1" \
402 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100403 0 \
404 -s "session successfully restored from cache" \
405 -S "session successfully restored from ticket" \
406 -s "a session has been resumed" \
407 -c "a session has been resumed"
408
409run_test "Session resume using cache #5 (timemout > delay)" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100410 "$P_SRV debug_level=4 tickets=0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100411 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100412 0 \
413 -s "session successfully restored from cache" \
414 -S "session successfully restored from ticket" \
415 -s "a session has been resumed" \
416 -c "a session has been resumed"
417
418run_test "Session resume using cache #6 (timeout < delay)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100419 "$P_SRV debug_level=4 tickets=0 cache_timeout=1" \
420 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100421 0 \
422 -S "session successfully restored from cache" \
423 -S "session successfully restored from ticket" \
424 -S "a session has been resumed" \
425 -C "a session has been resumed"
426
427run_test "Session resume using cache #7 (no timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100428 "$P_SRV debug_level=4 tickets=0 cache_timeout=0" \
429 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100430 0 \
431 -s "session successfully restored from cache" \
432 -S "session successfully restored from ticket" \
433 -s "a session has been resumed" \
434 -c "a session has been resumed"
435
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100436run_test "Session resume using cache #8 (openssl client)" \
437 "$P_SRV debug_level=4 tickets=0" \
438 "($O_CLI -sess_out sess; $O_CLI -sess_in sess; rm -f sess)" \
439 0 \
440 -s "found session ticket extension" \
441 -S "server hello, adding session ticket extension" \
442 -s "session successfully restored from cache" \
443 -S "session successfully restored from ticket" \
444 -s "a session has been resumed"
445
446run_test "Session resume using cache #9 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100447 "$O_SRV" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100448 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
449 0 \
450 -C "found session_ticket extension" \
451 -C "parse new session ticket" \
452 -c "a session has been resumed"
453
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100454# Tests for Max Fragment Length extension
455
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100456run_test "Max fragment length #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100457 "$P_SRV debug_level=4" \
458 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100459 0 \
460 -C "client hello, adding max_fragment_length extension" \
461 -S "found max fragment length extension" \
462 -S "server hello, max_fragment_length extension" \
463 -C "found max_fragment_length extension"
464
465run_test "Max fragment length #2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100466 "$P_SRV debug_level=4" \
467 "$P_CLI debug_level=4 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100468 0 \
469 -c "client hello, adding max_fragment_length extension" \
470 -s "found max fragment length extension" \
471 -s "server hello, max_fragment_length extension" \
472 -c "found max_fragment_length extension"
473
474run_test "Max fragment length #3" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100475 "$P_SRV debug_level=4 max_frag_len=4096" \
476 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100477 0 \
478 -C "client hello, adding max_fragment_length extension" \
479 -S "found max fragment length extension" \
480 -S "server hello, max_fragment_length extension" \
481 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100482
483# Tests for renegotiation
484
485run_test "Renegotiation #0 (none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100486 "$P_SRV debug_level=4" \
487 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100488 0 \
489 -C "client hello, adding renegotiation extension" \
490 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
491 -S "found renegotiation extension" \
492 -s "server hello, secure renegotiation extension" \
493 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100494 -C "=> renegotiate" \
495 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100496 -S "write hello request"
497
498run_test "Renegotiation #1 (enabled, client-initiated)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100499 "$P_SRV debug_level=4" \
500 "$P_CLI debug_level=4 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100501 0 \
502 -c "client hello, adding renegotiation extension" \
503 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
504 -s "found renegotiation extension" \
505 -s "server hello, secure renegotiation extension" \
506 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100507 -c "=> renegotiate" \
508 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100509 -S "write hello request"
510
511run_test "Renegotiation #2 (enabled, server-initiated)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100512 "$P_SRV debug_level=4 renegotiate=1" \
513 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100514 0 \
515 -c "client hello, adding renegotiation extension" \
516 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
517 -s "found renegotiation extension" \
518 -s "server hello, secure renegotiation extension" \
519 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100520 -c "=> renegotiate" \
521 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100522 -s "write hello request"
523
524run_test "Renegotiation #3 (enabled, double)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100525 "$P_SRV debug_level=4 renegotiate=1" \
526 "$P_CLI debug_level=4 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100527 0 \
528 -c "client hello, adding renegotiation extension" \
529 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
530 -s "found renegotiation extension" \
531 -s "server hello, secure renegotiation extension" \
532 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100533 -c "=> renegotiate" \
534 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100535 -s "write hello request"
536
537run_test "Renegotiation #4 (client-initiated, server-rejected)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100538 "$P_SRV debug_level=4 renegotiation=0" \
539 "$P_CLI debug_level=4 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100540 1 \
541 -c "client hello, adding renegotiation extension" \
542 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
543 -S "found renegotiation extension" \
544 -s "server hello, secure renegotiation extension" \
545 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100546 -c "=> renegotiate" \
547 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100548 -S "write hello request"
549
550run_test "Renegotiation #5 (server-initiated, client-rejected)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100551 "$P_SRV debug_level=4 renegotiate=1" \
552 "$P_CLI debug_level=4 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100553 0 \
554 -C "client hello, adding renegotiation extension" \
555 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
556 -S "found renegotiation extension" \
557 -s "server hello, secure renegotiation extension" \
558 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100559 -C "=> renegotiate" \
560 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100561 -s "write hello request" \
562 -s "SSL - An unexpected message was received from our peer" \
563 -s "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100564
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100565# Tests for auth_mode
566
567run_test "Authentication #1 (server badcert, client required)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100568 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100569 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100570 "$P_CLI debug_level=2 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100571 1 \
572 -c "x509_verify_cert() returned" \
573 -c "! self-signed or not signed by a trusted CA" \
574 -c "! ssl_handshake returned" \
575 -c "X509 - Certificate verification failed"
576
577run_test "Authentication #2 (server badcert, client optional)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100578 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100579 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100580 "$P_CLI debug_level=2 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100581 0 \
582 -c "x509_verify_cert() returned" \
583 -c "! self-signed or not signed by a trusted CA" \
584 -C "! ssl_handshake returned" \
585 -C "X509 - Certificate verification failed"
586
587run_test "Authentication #3 (server badcert, client none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100588 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100589 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100590 "$P_CLI debug_level=2 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100591 0 \
592 -C "x509_verify_cert() returned" \
593 -C "! self-signed or not signed by a trusted CA" \
594 -C "! ssl_handshake returned" \
595 -C "X509 - Certificate verification failed"
596
597run_test "Authentication #4 (client badcert, server required)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100598 "$P_SRV debug_level=4 auth_mode=required" \
599 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100600 key_file=data_files/server5.key" \
601 1 \
602 -S "skip write certificate request" \
603 -C "skip parse certificate request" \
604 -c "got a certificate request" \
605 -C "skip write certificate" \
606 -C "skip write certificate verify" \
607 -S "skip parse certificate verify" \
608 -s "x509_verify_cert() returned" \
609 -S "! self-signed or not signed by a trusted CA" \
610 -s "! ssl_handshake returned" \
611 -c "! ssl_handshake returned" \
612 -s "X509 - Certificate verification failed"
613
614run_test "Authentication #5 (client badcert, server optional)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100615 "$P_SRV debug_level=4 auth_mode=optional" \
616 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100617 key_file=data_files/server5.key" \
618 0 \
619 -S "skip write certificate request" \
620 -C "skip parse certificate request" \
621 -c "got a certificate request" \
622 -C "skip write certificate" \
623 -C "skip write certificate verify" \
624 -S "skip parse certificate verify" \
625 -s "x509_verify_cert() returned" \
626 -s "! self-signed or not signed by a trusted CA" \
627 -S "! ssl_handshake returned" \
628 -C "! ssl_handshake returned" \
629 -S "X509 - Certificate verification failed"
630
631run_test "Authentication #6 (client badcert, server none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100632 "$P_SRV debug_level=4 auth_mode=none" \
633 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100634 key_file=data_files/server5.key" \
635 0 \
636 -s "skip write certificate request" \
637 -C "skip parse certificate request" \
638 -c "got no certificate request" \
639 -c "skip write certificate" \
640 -c "skip write certificate verify" \
641 -s "skip parse certificate verify" \
642 -S "x509_verify_cert() returned" \
643 -S "! self-signed or not signed by a trusted CA" \
644 -S "! ssl_handshake returned" \
645 -C "! ssl_handshake returned" \
646 -S "X509 - Certificate verification failed"
647
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100648run_test "Authentication #7 (client no cert, server optional)" \
649 "$P_SRV debug_level=4 auth_mode=optional" \
650 "$P_CLI debug_level=4 crt_file=none key_file=none" \
651 0 \
652 -S "skip write certificate request" \
653 -C "skip parse certificate request" \
654 -c "got a certificate request" \
655 -C "skip write certificate$" \
656 -C "got no certificate to send" \
657 -S "SSLv3 client has no certificate" \
658 -c "skip write certificate verify" \
659 -s "skip parse certificate verify" \
660 -s "! no client certificate sent" \
661 -S "! ssl_handshake returned" \
662 -C "! ssl_handshake returned" \
663 -S "X509 - Certificate verification failed"
664
665run_test "Authentication #8 (openssl client no cert, server optional)" \
666 "$P_SRV debug_level=4 auth_mode=optional" \
667 "$O_CLI" \
668 0 \
669 -S "skip write certificate request" \
670 -s "skip parse certificate verify" \
671 -s "! no client certificate sent" \
672 -S "! ssl_handshake returned" \
673 -S "X509 - Certificate verification failed"
674
675run_test "Authentication #9 (client no cert, openssl server optional)" \
676 "$O_SRV -verify 10" \
677 "$P_CLI debug_level=4 crt_file=none key_file=none" \
678 0 \
679 -C "skip parse certificate request" \
680 -c "got a certificate request" \
681 -C "skip write certificate$" \
682 -c "skip write certificate verify" \
683 -C "! ssl_handshake returned"
684
685run_test "Authentication #10 (client no cert, ssl3)" \
686 "$P_SRV debug_level=4 auth_mode=optional force_version=ssl3" \
687 "$P_CLI debug_level=4 crt_file=none key_file=none" \
688 0 \
689 -S "skip write certificate request" \
690 -C "skip parse certificate request" \
691 -c "got a certificate request" \
692 -C "skip write certificate$" \
693 -c "skip write certificate verify" \
694 -c "got no certificate to send" \
695 -s "SSLv3 client has no certificate" \
696 -s "skip parse certificate verify" \
697 -s "! no client certificate sent" \
698 -S "! ssl_handshake returned" \
699 -C "! ssl_handshake returned" \
700 -S "X509 - Certificate verification failed"
701
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100702# tests for SNI
703
704run_test "SNI #0 (no SNI callback)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100705 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100706 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100707 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100708 server_name=localhost" \
709 0 \
710 -S "parse ServerName extension" \
711 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
712 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
713
714run_test "SNI #1 (matching cert 1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100715 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100716 crt_file=data_files/server5.crt key_file=data_files/server5.key \
717 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 +0100718 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100719 server_name=localhost" \
720 0 \
721 -s "parse ServerName extension" \
722 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
723 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
724
725run_test "SNI #2 (matching cert 2)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100726 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100727 crt_file=data_files/server5.crt key_file=data_files/server5.key \
728 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 +0100729 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100730 server_name='PolarSSL Server 1'" \
731 0 \
732 -s "parse ServerName extension" \
733 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
734 -c "subject name *: C=NL, O=PolarSSL, CN=PolarSSL Server 1"
735
736run_test "SNI #3 (no matching cert)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100737 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100738 crt_file=data_files/server5.crt key_file=data_files/server5.key \
739 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 +0100740 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100741 server_name='PolarSSL Server 2'" \
742 1 \
743 -s "parse ServerName extension" \
744 -s "ssl_sni_wrapper() returned" \
745 -s "ssl_handshake returned" \
746 -c "ssl_handshake returned" \
747 -c "SSL - A fatal alert message was received from our peer"
748
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +0100749# Tests for non-blocking I/O: exercise a variety of handshake flows
750
751run_test "Non-blocking I/O #1 (basic handshake)" \
752 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
753 "$P_CLI nbio=2 tickets=0" \
754 0 \
755 -S "ssl_handshake returned" \
756 -C "ssl_handshake returned" \
757 -c "Read from server: .* bytes read"
758
759run_test "Non-blocking I/O #2 (client auth)" \
760 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
761 "$P_CLI nbio=2 tickets=0" \
762 0 \
763 -S "ssl_handshake returned" \
764 -C "ssl_handshake returned" \
765 -c "Read from server: .* bytes read"
766
767run_test "Non-blocking I/O #3 (ticket)" \
768 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
769 "$P_CLI nbio=2 tickets=1" \
770 0 \
771 -S "ssl_handshake returned" \
772 -C "ssl_handshake returned" \
773 -c "Read from server: .* bytes read"
774
775run_test "Non-blocking I/O #4 (ticket + client auth)" \
776 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
777 "$P_CLI nbio=2 tickets=1" \
778 0 \
779 -S "ssl_handshake returned" \
780 -C "ssl_handshake returned" \
781 -c "Read from server: .* bytes read"
782
783run_test "Non-blocking I/O #5 (ticket + client auth + resume)" \
784 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
785 "$P_CLI nbio=2 tickets=1 reconnect=1" \
786 0 \
787 -S "ssl_handshake returned" \
788 -C "ssl_handshake returned" \
789 -c "Read from server: .* bytes read"
790
791run_test "Non-blocking I/O #6 (ticket + resume)" \
792 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
793 "$P_CLI nbio=2 tickets=1 reconnect=1" \
794 0 \
795 -S "ssl_handshake returned" \
796 -C "ssl_handshake returned" \
797 -c "Read from server: .* bytes read"
798
799run_test "Non-blocking I/O #7 (session-id resume)" \
800 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
801 "$P_CLI nbio=2 tickets=0 reconnect=1" \
802 0 \
803 -S "ssl_handshake returned" \
804 -C "ssl_handshake returned" \
805 -c "Read from server: .* bytes read"
806
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100807run_test "Version check #1 (all -> 1.2)" \
808 "$P_SRV" \
809 "$P_CLI" \
810 0 \
811 -S "ssl_handshake returned" \
812 -C "ssl_handshake returned" \
813 -s "Protocol is TLSv1.2" \
814 -c "Protocol is TLSv1.2"
815
816run_test "Version check #2 (cli max 1.1 -> 1.1)" \
817 "$P_SRV" \
818 "$P_CLI max_version=tls1_1" \
819 0 \
820 -S "ssl_handshake returned" \
821 -C "ssl_handshake returned" \
822 -s "Protocol is TLSv1.1" \
823 -c "Protocol is TLSv1.1"
824
825run_test "Version check #3 (srv max 1.1 -> 1.1)" \
826 "$P_SRV max_version=tls1_1" \
827 "$P_CLI" \
828 0 \
829 -S "ssl_handshake returned" \
830 -C "ssl_handshake returned" \
831 -s "Protocol is TLSv1.1" \
832 -c "Protocol is TLSv1.1"
833
834run_test "Version check #4 (cli+srv max 1.1 -> 1.1)" \
835 "$P_SRV max_version=tls1_1" \
836 "$P_CLI max_version=tls1_1" \
837 0 \
838 -S "ssl_handshake returned" \
839 -C "ssl_handshake returned" \
840 -s "Protocol is TLSv1.1" \
841 -c "Protocol is TLSv1.1"
842
843run_test "Version check #5 (cli max 1.1, srv min 1.1 -> 1.1)" \
844 "$P_SRV min_version=tls1_1" \
845 "$P_CLI max_version=tls1_1" \
846 0 \
847 -S "ssl_handshake returned" \
848 -C "ssl_handshake returned" \
849 -s "Protocol is TLSv1.1" \
850 -c "Protocol is TLSv1.1"
851
852run_test "Version check #6 (cli min 1.1, srv max 1.1 -> 1.1)" \
853 "$P_SRV max_version=tls1_1" \
854 "$P_CLI min_version=tls1_1" \
855 0 \
856 -S "ssl_handshake returned" \
857 -C "ssl_handshake returned" \
858 -s "Protocol is TLSv1.1" \
859 -c "Protocol is TLSv1.1"
860
861run_test "Version check #7 (cli min 1.2, srv max 1.1 -> fail)" \
862 "$P_SRV max_version=tls1_1" \
863 "$P_CLI min_version=tls1_2" \
864 1 \
865 -s "ssl_handshake returned" \
866 -c "ssl_handshake returned" \
867 -c "SSL - Handshake protocol not within min/max boundaries"
868
869run_test "Version check #8 (srv min 1.2, cli max 1.1 -> fail)" \
870 "$P_SRV min_version=tls1_2" \
871 "$P_CLI max_version=tls1_1" \
872 1 \
873 -s "ssl_handshake returned" \
874 -c "ssl_handshake returned" \
875 -s "SSL - Handshake protocol not within min/max boundaries"
876
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100877# Final report
878
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100879echo "------------------------------------------------------------------------"
880
881if [ $FAILS = 0 ]; then
882 echo -n "PASSED"
883else
884 echo -n "FAILED"
885fi
886PASSES=`echo $TESTS - $FAILS | bc`
Manuel Pégourié-Gonnard4145b892014-02-24 13:20:14 +0100887echo " ($PASSES / $TESTS tests)"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100888
889exit $FAILS