blob: 19be5ef2b2650410f72fb82422a9c177f469f76f [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é-Gonnard913030c2014-03-28 10:12:38 +010013# test if it is defined from the environment before assining default
14# if yes, assume it means it's a build with all the options we need (SSLv2)
15if [ -n "${OPENSSL_CMD:-}" ]; then
16 OPENSSL_OK=1
17else
18 OPENSSL_OK=0
19fi
20
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010021# default values, can be overriden by the environment
22: ${P_SRV:=../programs/ssl/ssl_server2}
23: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010024: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010025
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010026O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
27O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010028
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010029TESTS=0
30FAILS=0
31
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020032CONFIG_H='../include/polarssl/config.h'
33
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010035FILTER='.*'
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +010036if [ "$OPENSSL_OK" -gt 0 ]; then
37 EXCLUDE='^$'
38else
39 EXCLUDE='SSLv2'
40fi
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041
42print_usage() {
43 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010044 echo -e " -h|--help\tPrint this help."
45 echo -e " -m|--memcheck\tCheck memory leaks and errors."
46 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
47 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048}
49
50get_options() {
51 while [ $# -gt 0 ]; do
52 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010053 -f|--filter)
54 shift; FILTER=$1
55 ;;
56 -e|--exclude)
57 shift; EXCLUDE=$1
58 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010059 -m|--memcheck)
60 MEMCHECK=1
61 ;;
62 -h|--help)
63 print_usage
64 exit 0
65 ;;
66 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020067 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010068 print_usage
69 exit 1
70 ;;
71 esac
72 shift
73 done
74}
75
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010076# print_name <name>
77print_name() {
78 echo -n "$1 "
79 LEN=`echo "$1" | wc -c`
80 LEN=`echo 72 - $LEN | bc`
81 for i in `seq 1 $LEN`; do echo -n '.'; done
82 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010083
84 TESTS=`echo $TESTS + 1 | bc`
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010085}
86
87# fail <message>
88fail() {
89 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +010090 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010091
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +020092 cp $SRV_OUT o-srv-${TESTS}.log
93 cp $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +010094 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010095
96 FAILS=`echo $FAILS + 1 | bc`
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +010097}
98
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +010099# is_polar <cmd_line>
100is_polar() {
101 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
102}
103
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104# has_mem_err <log_file_name>
105has_mem_err() {
106 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
107 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
108 then
109 return 1 # false: does not have errors
110 else
111 return 0 # true: has errors
112 fi
113}
114
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100115# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100116# Options: -s pattern pattern that must be present in server output
117# -c pattern pattern that must be present in client output
118# -S pattern pattern that must be absent in server output
119# -C pattern pattern that must be absent in client output
120run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100121 NAME="$1"
122 SRV_CMD="$2"
123 CLI_CMD="$3"
124 CLI_EXPECT="$4"
125 shift 4
126
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100127 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
128 else
129 return
130 fi
131
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100132 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100133
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100134 # prepend valgrind to our commands if active
135 if [ "$MEMCHECK" -gt 0 ]; then
136 if is_polar "$SRV_CMD"; then
137 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
138 fi
139 if is_polar "$CLI_CMD"; then
140 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
141 fi
142 fi
143
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100144 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200145 echo "$SRV_CMD" > $SRV_OUT
146 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100147 SRV_PID=$!
148 sleep 1
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200149 echo "$CLI_CMD" > $CLI_OUT
150 eval "$CLI_CMD" >> $CLI_OUT 2>&1
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100151 CLI_EXIT=$?
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200152 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100153
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200154 # psk is useful when server only has bad certs
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100155 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200156 $P_CLI request_page=SERVERQUIT tickets=0 auth_mode=none psk=abc123 \
Manuel Pégourié-Gonnard84fd6872014-03-13 18:35:10 +0100157 crt_file=data_files/cli2.crt key_file=data_files/cli2.key \
158 >/dev/null
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100159 else
160 kill $SRV_PID
161 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100162 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100163
164 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200165 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100166 # expected client exit to incorrectly succeed in case of catastrophic
167 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100168 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200169 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100170 else
171 fail "server failed to start"
172 return
173 fi
174 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100175 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200176 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100177 else
178 fail "client failed to start"
179 return
180 fi
181 fi
182
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100183 # check server exit code
184 if [ $? != 0 ]; then
185 fail "server fail"
186 return
187 fi
188
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100189 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100190 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
191 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100192 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100193 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100194 return
195 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100196
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100197 # check other assertions
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100198 while [ $# -gt 0 ]
199 do
200 case $1 in
201 "-s")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200202 if grep "$2" $SRV_OUT >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100203 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100204 return
205 fi
206 ;;
207
208 "-c")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200209 if grep "$2" $CLI_OUT >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100210 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100211 return
212 fi
213 ;;
214
215 "-S")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200216 if grep "$2" $SRV_OUT >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100217 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100218 return
219 fi
220 ;;
221
222 "-C")
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200223 if grep "$2" $CLI_OUT >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100224 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100225 return
226 fi
227 ;;
228
229 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200230 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100231 exit 1
232 esac
233 shift 2
234 done
235
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100236 # check valgrind's results
237 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200238 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100239 fail "Server has memory errors"
240 return
241 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200242 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100243 fail "Client has memory errors"
244 return
245 fi
246 fi
247
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100248 # if we're here, everything is ok
249 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200250 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100251}
252
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100253cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200254 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100255 kill $SRV_PID
256 exit 1
257}
258
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100259#
260# MAIN
261#
262
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100263get_options "$@"
264
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100265# sanity checks, avoid an avalanche of errors
266if [ ! -x "$P_SRV" ]; then
267 echo "Command '$P_SRV' is not an executable file"
268 exit 1
269fi
270if [ ! -x "$P_CLI" ]; then
271 echo "Command '$P_CLI' is not an executable file"
272 exit 1
273fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100274if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
275 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100276 exit 1
277fi
278
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200279# Pick a "unique" port in the range 10000-19999.
280PORT="0000$$"
281PORT="1$(echo $PORT | tail -c 4)"
282
283# fix commands to use this port
284P_SRV="$P_SRV server_port=$PORT"
285P_CLI="$P_CLI server_port=$PORT"
286O_SRV="$O_SRV -accept $PORT"
287O_CLI="$O_CLI -connect localhost:$PORT"
288
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200289# Also pick a unique name for intermediate files
290SRV_OUT="srv_out.$$"
291CLI_OUT="cli_out.$$"
292SESSION="session.$$"
293
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100294trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100295
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100296# Test for SSLv2 ClientHello
297
298run_test "SSLv2 ClientHello #0 (reference)" \
299 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100300 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100301 0 \
302 -S "parse client hello v2" \
303 -S "ssl_handshake returned"
304
305# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
306run_test "SSLv2 ClientHello #1 (actual test)" \
307 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100308 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100309 0 \
310 -s "parse client hello v2" \
311 -S "ssl_handshake returned"
312
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100313# Tests for Truncated HMAC extension
314
315run_test "Truncated HMAC #0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100316 "$P_SRV debug_level=5" \
317 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100318 0 \
319 -s "dumping 'computed mac' (20 bytes)"
320
321run_test "Truncated HMAC #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100322 "$P_SRV debug_level=5" \
323 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100324 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100325 -s "dumping 'computed mac' (10 bytes)"
326
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100327# Tests for Session Tickets
328
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100329run_test "Session resume using tickets #1 (basic)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100330 "$P_SRV debug_level=4 tickets=1" \
331 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100332 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100333 -c "client hello, adding session ticket extension" \
334 -s "found session ticket extension" \
335 -s "server hello, adding session ticket extension" \
336 -c "found session_ticket extension" \
337 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100338 -S "session successfully restored from cache" \
339 -s "session successfully restored from ticket" \
340 -s "a session has been resumed" \
341 -c "a session has been resumed"
342
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100343run_test "Session resume using tickets #2 (cache disabled)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100344 "$P_SRV debug_level=4 tickets=1 cache_max=0" \
345 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100346 0 \
347 -c "client hello, adding session ticket extension" \
348 -s "found session ticket extension" \
349 -s "server hello, adding session ticket extension" \
350 -c "found session_ticket extension" \
351 -c "parse new session ticket" \
352 -S "session successfully restored from cache" \
353 -s "session successfully restored from ticket" \
354 -s "a session has been resumed" \
355 -c "a session has been resumed"
356
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100357run_test "Session resume using tickets #3 (timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100358 "$P_SRV debug_level=4 tickets=1 cache_max=0 ticket_timeout=1" \
359 "$P_CLI debug_level=4 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100360 0 \
361 -c "client hello, adding session ticket extension" \
362 -s "found session ticket extension" \
363 -s "server hello, adding session ticket extension" \
364 -c "found session_ticket extension" \
365 -c "parse new session ticket" \
366 -S "session successfully restored from cache" \
367 -S "session successfully restored from ticket" \
368 -S "a session has been resumed" \
369 -C "a session has been resumed"
370
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100371run_test "Session resume using tickets #4 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100372 "$O_SRV" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100373 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
374 0 \
375 -c "client hello, adding session ticket extension" \
376 -c "found session_ticket extension" \
377 -c "parse new session ticket" \
378 -c "a session has been resumed"
379
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100380run_test "Session resume using tickets #5 (openssl client)" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100381 "$P_SRV debug_level=4 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200382 "( $O_CLI -sess_out $SESSION; \
383 $O_CLI -sess_in $SESSION; \
384 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100385 0 \
386 -s "found session ticket extension" \
387 -s "server hello, adding session ticket extension" \
388 -S "session successfully restored from cache" \
389 -s "session successfully restored from ticket" \
390 -s "a session has been resumed"
391
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100392# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100393
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100394run_test "Session resume using cache #1 (tickets enabled on client)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100395 "$P_SRV debug_level=4 tickets=0" \
396 "$P_CLI debug_level=4 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100397 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100398 -c "client hello, adding session ticket extension" \
399 -s "found session ticket extension" \
400 -S "server hello, adding session ticket extension" \
401 -C "found session_ticket extension" \
402 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100403 -s "session successfully restored from cache" \
404 -S "session successfully restored from ticket" \
405 -s "a session has been resumed" \
406 -c "a session has been resumed"
407
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100408run_test "Session resume using cache #2 (tickets enabled on server)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100409 "$P_SRV debug_level=4 tickets=1" \
410 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100411 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100412 -C "client hello, adding session ticket extension" \
413 -S "found session ticket extension" \
414 -S "server hello, adding session ticket extension" \
415 -C "found session_ticket extension" \
416 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100417 -s "session successfully restored from cache" \
418 -S "session successfully restored from ticket" \
419 -s "a session has been resumed" \
420 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100421
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100422run_test "Session resume using cache #3 (cache_max=0)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100423 "$P_SRV debug_level=4 tickets=0 cache_max=0" \
424 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100425 0 \
426 -S "session successfully restored from cache" \
427 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100428 -S "a session has been resumed" \
429 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100430
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100431run_test "Session resume using cache #4 (cache_max=1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100432 "$P_SRV debug_level=4 tickets=0 cache_max=1" \
433 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100434 0 \
435 -s "session successfully restored from cache" \
436 -S "session successfully restored from ticket" \
437 -s "a session has been resumed" \
438 -c "a session has been resumed"
439
440run_test "Session resume using cache #5 (timemout > delay)" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100441 "$P_SRV debug_level=4 tickets=0" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100442 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100443 0 \
444 -s "session successfully restored from cache" \
445 -S "session successfully restored from ticket" \
446 -s "a session has been resumed" \
447 -c "a session has been resumed"
448
449run_test "Session resume using cache #6 (timeout < delay)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100450 "$P_SRV debug_level=4 tickets=0 cache_timeout=1" \
451 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100452 0 \
453 -S "session successfully restored from cache" \
454 -S "session successfully restored from ticket" \
455 -S "a session has been resumed" \
456 -C "a session has been resumed"
457
458run_test "Session resume using cache #7 (no timeout)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100459 "$P_SRV debug_level=4 tickets=0 cache_timeout=0" \
460 "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100461 0 \
462 -s "session successfully restored from cache" \
463 -S "session successfully restored from ticket" \
464 -s "a session has been resumed" \
465 -c "a session has been resumed"
466
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100467run_test "Session resume using cache #8 (openssl client)" \
468 "$P_SRV debug_level=4 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200469 "( $O_CLI -sess_out $SESSION; \
470 $O_CLI -sess_in $SESSION; \
471 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100472 0 \
473 -s "found session ticket extension" \
474 -S "server hello, adding session ticket extension" \
475 -s "session successfully restored from cache" \
476 -S "session successfully restored from ticket" \
477 -s "a session has been resumed"
478
479run_test "Session resume using cache #9 (openssl server)" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100480 "$O_SRV" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100481 "$P_CLI debug_level=4 tickets=0 reconnect=1" \
482 0 \
483 -C "found session_ticket extension" \
484 -C "parse new session ticket" \
485 -c "a session has been resumed"
486
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100487# Tests for Max Fragment Length extension
488
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100489run_test "Max fragment length #1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100490 "$P_SRV debug_level=4" \
491 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100492 0 \
493 -C "client hello, adding max_fragment_length extension" \
494 -S "found max fragment length extension" \
495 -S "server hello, max_fragment_length extension" \
496 -C "found max_fragment_length extension"
497
498run_test "Max fragment length #2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100499 "$P_SRV debug_level=4" \
500 "$P_CLI debug_level=4 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100501 0 \
502 -c "client hello, adding max_fragment_length extension" \
503 -s "found max fragment length extension" \
504 -s "server hello, max_fragment_length extension" \
505 -c "found max_fragment_length extension"
506
507run_test "Max fragment length #3" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100508 "$P_SRV debug_level=4 max_frag_len=4096" \
509 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100510 0 \
511 -C "client hello, adding max_fragment_length extension" \
512 -S "found max fragment length extension" \
513 -S "server hello, max_fragment_length extension" \
514 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100515
516# Tests for renegotiation
517
518run_test "Renegotiation #0 (none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100519 "$P_SRV debug_level=4" \
520 "$P_CLI debug_level=4" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100521 0 \
522 -C "client hello, adding renegotiation extension" \
523 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
524 -S "found renegotiation extension" \
525 -s "server hello, secure renegotiation extension" \
526 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100527 -C "=> renegotiate" \
528 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100529 -S "write hello request"
530
531run_test "Renegotiation #1 (enabled, client-initiated)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200532 "$P_SRV debug_level=4 renegotiation=1" \
533 "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100534 0 \
535 -c "client hello, adding renegotiation extension" \
536 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
537 -s "found renegotiation extension" \
538 -s "server hello, secure renegotiation extension" \
539 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100540 -c "=> renegotiate" \
541 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100542 -S "write hello request"
543
544run_test "Renegotiation #2 (enabled, server-initiated)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200545 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \
546 "$P_CLI debug_level=4 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100547 0 \
548 -c "client hello, adding renegotiation extension" \
549 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
550 -s "found renegotiation extension" \
551 -s "server hello, secure renegotiation extension" \
552 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100553 -c "=> renegotiate" \
554 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100555 -s "write hello request"
556
557run_test "Renegotiation #3 (enabled, double)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200558 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \
559 "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100560 0 \
561 -c "client hello, adding renegotiation extension" \
562 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
563 -s "found renegotiation extension" \
564 -s "server hello, secure renegotiation extension" \
565 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100566 -c "=> renegotiate" \
567 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100568 -s "write hello request"
569
570run_test "Renegotiation #4 (client-initiated, server-rejected)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100571 "$P_SRV debug_level=4 renegotiation=0" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200572 "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100573 1 \
574 -c "client hello, adding renegotiation extension" \
575 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
576 -S "found renegotiation extension" \
577 -s "server hello, secure renegotiation extension" \
578 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100579 -c "=> renegotiate" \
580 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100581 -S "write hello request"
582
583run_test "Renegotiation #5 (server-initiated, client-rejected)" \
Manuel Pégourié-Gonnard00d538f2014-03-31 10:44:40 +0200584 "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100585 "$P_CLI debug_level=4 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100586 0 \
587 -C "client hello, adding renegotiation extension" \
588 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
589 -S "found renegotiation extension" \
590 -s "server hello, secure renegotiation extension" \
591 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100592 -C "=> renegotiate" \
593 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100594 -s "write hello request" \
595 -s "SSL - An unexpected message was received from our peer" \
596 -s "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100597
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100598# Tests for auth_mode
599
600run_test "Authentication #1 (server badcert, client required)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100601 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100602 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100603 "$P_CLI debug_level=2 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100604 1 \
605 -c "x509_verify_cert() returned" \
606 -c "! self-signed or not signed by a trusted CA" \
607 -c "! ssl_handshake returned" \
608 -c "X509 - Certificate verification failed"
609
610run_test "Authentication #2 (server badcert, client optional)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100611 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100612 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100613 "$P_CLI debug_level=2 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100614 0 \
615 -c "x509_verify_cert() returned" \
616 -c "! self-signed or not signed by a trusted CA" \
617 -C "! ssl_handshake returned" \
618 -C "X509 - Certificate verification failed"
619
620run_test "Authentication #3 (server badcert, client none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100621 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100622 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100623 "$P_CLI debug_level=2 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100624 0 \
625 -C "x509_verify_cert() returned" \
626 -C "! self-signed or not signed by a trusted CA" \
627 -C "! ssl_handshake returned" \
628 -C "X509 - Certificate verification failed"
629
630run_test "Authentication #4 (client badcert, server required)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100631 "$P_SRV debug_level=4 auth_mode=required" \
632 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100633 key_file=data_files/server5.key" \
634 1 \
635 -S "skip write certificate request" \
636 -C "skip parse certificate request" \
637 -c "got a certificate request" \
638 -C "skip write certificate" \
639 -C "skip write certificate verify" \
640 -S "skip parse certificate verify" \
641 -s "x509_verify_cert() returned" \
642 -S "! self-signed or not signed by a trusted CA" \
643 -s "! ssl_handshake returned" \
644 -c "! ssl_handshake returned" \
645 -s "X509 - Certificate verification failed"
646
647run_test "Authentication #5 (client badcert, server optional)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100648 "$P_SRV debug_level=4 auth_mode=optional" \
649 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100650 key_file=data_files/server5.key" \
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 "skip write certificate verify" \
657 -S "skip parse certificate verify" \
658 -s "x509_verify_cert() returned" \
659 -s "! self-signed or not signed by a trusted CA" \
660 -S "! ssl_handshake returned" \
661 -C "! ssl_handshake returned" \
662 -S "X509 - Certificate verification failed"
663
664run_test "Authentication #6 (client badcert, server none)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100665 "$P_SRV debug_level=4 auth_mode=none" \
666 "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100667 key_file=data_files/server5.key" \
668 0 \
669 -s "skip write certificate request" \
670 -C "skip parse certificate request" \
671 -c "got no certificate request" \
672 -c "skip write certificate" \
673 -c "skip write certificate verify" \
674 -s "skip parse certificate verify" \
675 -S "x509_verify_cert() returned" \
676 -S "! self-signed or not signed by a trusted CA" \
677 -S "! ssl_handshake returned" \
678 -C "! ssl_handshake returned" \
679 -S "X509 - Certificate verification failed"
680
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100681run_test "Authentication #7 (client no cert, server optional)" \
682 "$P_SRV debug_level=4 auth_mode=optional" \
683 "$P_CLI debug_level=4 crt_file=none key_file=none" \
684 0 \
685 -S "skip write certificate request" \
686 -C "skip parse certificate request" \
687 -c "got a certificate request" \
688 -C "skip write certificate$" \
689 -C "got no certificate to send" \
690 -S "SSLv3 client has no certificate" \
691 -c "skip write certificate verify" \
692 -s "skip parse certificate verify" \
693 -s "! no client certificate sent" \
694 -S "! ssl_handshake returned" \
695 -C "! ssl_handshake returned" \
696 -S "X509 - Certificate verification failed"
697
698run_test "Authentication #8 (openssl client no cert, server optional)" \
699 "$P_SRV debug_level=4 auth_mode=optional" \
700 "$O_CLI" \
701 0 \
702 -S "skip write certificate request" \
703 -s "skip parse certificate verify" \
704 -s "! no client certificate sent" \
705 -S "! ssl_handshake returned" \
706 -S "X509 - Certificate verification failed"
707
708run_test "Authentication #9 (client no cert, openssl server optional)" \
709 "$O_SRV -verify 10" \
710 "$P_CLI debug_level=4 crt_file=none key_file=none" \
711 0 \
712 -C "skip parse certificate request" \
713 -c "got a certificate request" \
714 -C "skip write certificate$" \
715 -c "skip write certificate verify" \
716 -C "! ssl_handshake returned"
717
718run_test "Authentication #10 (client no cert, ssl3)" \
719 "$P_SRV debug_level=4 auth_mode=optional force_version=ssl3" \
720 "$P_CLI debug_level=4 crt_file=none key_file=none" \
721 0 \
722 -S "skip write certificate request" \
723 -C "skip parse certificate request" \
724 -c "got a certificate request" \
725 -C "skip write certificate$" \
726 -c "skip write certificate verify" \
727 -c "got no certificate to send" \
728 -s "SSLv3 client has no certificate" \
729 -s "skip parse certificate verify" \
730 -s "! no client certificate sent" \
731 -S "! ssl_handshake returned" \
732 -C "! ssl_handshake returned" \
733 -S "X509 - Certificate verification failed"
734
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100735# tests for SNI
736
737run_test "SNI #0 (no SNI callback)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100738 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100739 crt_file=data_files/server5.crt key_file=data_files/server5.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=localhost" \
742 0 \
743 -S "parse ServerName extension" \
744 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
745 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
746
747run_test "SNI #1 (matching cert 1)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100748 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100749 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100750 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100751 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100752 server_name=localhost" \
753 0 \
754 -s "parse ServerName extension" \
755 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
756 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
757
758run_test "SNI #2 (matching cert 2)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100759 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100760 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100761 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100762 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100763 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100764 0 \
765 -s "parse ServerName extension" \
766 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100767 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100768
769run_test "SNI #3 (no matching cert)" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100770 "$P_SRV debug_level=4 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100771 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100772 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100773 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +0100774 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +0100775 1 \
776 -s "parse ServerName extension" \
777 -s "ssl_sni_wrapper() returned" \
778 -s "ssl_handshake returned" \
779 -c "ssl_handshake returned" \
780 -c "SSL - A fatal alert message was received from our peer"
781
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +0100782# Tests for non-blocking I/O: exercise a variety of handshake flows
783
784run_test "Non-blocking I/O #1 (basic handshake)" \
785 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
786 "$P_CLI nbio=2 tickets=0" \
787 0 \
788 -S "ssl_handshake returned" \
789 -C "ssl_handshake returned" \
790 -c "Read from server: .* bytes read"
791
792run_test "Non-blocking I/O #2 (client auth)" \
793 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
794 "$P_CLI nbio=2 tickets=0" \
795 0 \
796 -S "ssl_handshake returned" \
797 -C "ssl_handshake returned" \
798 -c "Read from server: .* bytes read"
799
800run_test "Non-blocking I/O #3 (ticket)" \
801 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
802 "$P_CLI nbio=2 tickets=1" \
803 0 \
804 -S "ssl_handshake returned" \
805 -C "ssl_handshake returned" \
806 -c "Read from server: .* bytes read"
807
808run_test "Non-blocking I/O #4 (ticket + client auth)" \
809 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
810 "$P_CLI nbio=2 tickets=1" \
811 0 \
812 -S "ssl_handshake returned" \
813 -C "ssl_handshake returned" \
814 -c "Read from server: .* bytes read"
815
816run_test "Non-blocking I/O #5 (ticket + client auth + resume)" \
817 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
818 "$P_CLI nbio=2 tickets=1 reconnect=1" \
819 0 \
820 -S "ssl_handshake returned" \
821 -C "ssl_handshake returned" \
822 -c "Read from server: .* bytes read"
823
824run_test "Non-blocking I/O #6 (ticket + resume)" \
825 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
826 "$P_CLI nbio=2 tickets=1 reconnect=1" \
827 0 \
828 -S "ssl_handshake returned" \
829 -C "ssl_handshake returned" \
830 -c "Read from server: .* bytes read"
831
832run_test "Non-blocking I/O #7 (session-id resume)" \
833 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
834 "$P_CLI nbio=2 tickets=0 reconnect=1" \
835 0 \
836 -S "ssl_handshake returned" \
837 -C "ssl_handshake returned" \
838 -c "Read from server: .* bytes read"
839
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +0200840# Tests for version negotiation
841
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100842run_test "Version check #1 (all -> 1.2)" \
843 "$P_SRV" \
844 "$P_CLI" \
845 0 \
846 -S "ssl_handshake returned" \
847 -C "ssl_handshake returned" \
848 -s "Protocol is TLSv1.2" \
849 -c "Protocol is TLSv1.2"
850
851run_test "Version check #2 (cli max 1.1 -> 1.1)" \
852 "$P_SRV" \
853 "$P_CLI max_version=tls1_1" \
854 0 \
855 -S "ssl_handshake returned" \
856 -C "ssl_handshake returned" \
857 -s "Protocol is TLSv1.1" \
858 -c "Protocol is TLSv1.1"
859
860run_test "Version check #3 (srv max 1.1 -> 1.1)" \
861 "$P_SRV max_version=tls1_1" \
862 "$P_CLI" \
863 0 \
864 -S "ssl_handshake returned" \
865 -C "ssl_handshake returned" \
866 -s "Protocol is TLSv1.1" \
867 -c "Protocol is TLSv1.1"
868
869run_test "Version check #4 (cli+srv max 1.1 -> 1.1)" \
870 "$P_SRV max_version=tls1_1" \
871 "$P_CLI max_version=tls1_1" \
872 0 \
873 -S "ssl_handshake returned" \
874 -C "ssl_handshake returned" \
875 -s "Protocol is TLSv1.1" \
876 -c "Protocol is TLSv1.1"
877
878run_test "Version check #5 (cli max 1.1, srv min 1.1 -> 1.1)" \
879 "$P_SRV min_version=tls1_1" \
880 "$P_CLI max_version=tls1_1" \
881 0 \
882 -S "ssl_handshake returned" \
883 -C "ssl_handshake returned" \
884 -s "Protocol is TLSv1.1" \
885 -c "Protocol is TLSv1.1"
886
887run_test "Version check #6 (cli min 1.1, srv max 1.1 -> 1.1)" \
888 "$P_SRV max_version=tls1_1" \
889 "$P_CLI min_version=tls1_1" \
890 0 \
891 -S "ssl_handshake returned" \
892 -C "ssl_handshake returned" \
893 -s "Protocol is TLSv1.1" \
894 -c "Protocol is TLSv1.1"
895
896run_test "Version check #7 (cli min 1.2, srv max 1.1 -> fail)" \
897 "$P_SRV max_version=tls1_1" \
898 "$P_CLI min_version=tls1_2" \
899 1 \
900 -s "ssl_handshake returned" \
901 -c "ssl_handshake returned" \
902 -c "SSL - Handshake protocol not within min/max boundaries"
903
904run_test "Version check #8 (srv min 1.2, cli max 1.1 -> fail)" \
905 "$P_SRV min_version=tls1_2" \
906 "$P_CLI max_version=tls1_1" \
907 1 \
908 -s "ssl_handshake returned" \
909 -c "ssl_handshake returned" \
910 -s "SSL - Handshake protocol not within min/max boundaries"
911
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +0200912# Tests for ALPN extension
913
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +0200914if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
915
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +0200916run_test "ALPN #0 (none)" \
917 "$P_SRV debug_level=4" \
918 "$P_CLI debug_level=4" \
919 0 \
920 -C "client hello, adding alpn extension" \
921 -S "found alpn extension" \
922 -C "got an alert message, type: \\[2:120]" \
923 -S "server hello, adding alpn extension" \
924 -C "found alpn extension " \
925 -C "Application Layer Protocol is" \
926 -S "Application Layer Protocol is"
927
928run_test "ALPN #1 (client only)" \
929 "$P_SRV debug_level=4" \
930 "$P_CLI debug_level=4 alpn=abc,1234" \
931 0 \
932 -c "client hello, adding alpn extension" \
933 -s "found alpn extension" \
934 -C "got an alert message, type: \\[2:120]" \
935 -S "server hello, adding alpn extension" \
936 -C "found alpn extension " \
937 -c "Application Layer Protocol is (none)" \
938 -S "Application Layer Protocol is"
939
940run_test "ALPN #2 (server only)" \
941 "$P_SRV debug_level=4 alpn=abc,1234" \
942 "$P_CLI debug_level=4" \
943 0 \
944 -C "client hello, adding alpn extension" \
945 -S "found alpn extension" \
946 -C "got an alert message, type: \\[2:120]" \
947 -S "server hello, adding alpn extension" \
948 -C "found alpn extension " \
949 -C "Application Layer Protocol is" \
950 -s "Application Layer Protocol is (none)"
951
952run_test "ALPN #3 (both, common cli1-srv1)" \
953 "$P_SRV debug_level=4 alpn=abc,1234" \
954 "$P_CLI debug_level=4 alpn=abc,1234" \
955 0 \
956 -c "client hello, adding alpn extension" \
957 -s "found alpn extension" \
958 -C "got an alert message, type: \\[2:120]" \
959 -s "server hello, adding alpn extension" \
960 -c "found alpn extension" \
961 -c "Application Layer Protocol is abc" \
962 -s "Application Layer Protocol is abc"
963
964run_test "ALPN #4 (both, common cli2-srv1)" \
965 "$P_SRV debug_level=4 alpn=abc,1234" \
966 "$P_CLI debug_level=4 alpn=1234,abc" \
967 0 \
968 -c "client hello, adding alpn extension" \
969 -s "found alpn extension" \
970 -C "got an alert message, type: \\[2:120]" \
971 -s "server hello, adding alpn extension" \
972 -c "found alpn extension" \
973 -c "Application Layer Protocol is abc" \
974 -s "Application Layer Protocol is abc"
975
976run_test "ALPN #5 (both, common cli1-srv2)" \
977 "$P_SRV debug_level=4 alpn=abc,1234" \
978 "$P_CLI debug_level=4 alpn=1234,abcde" \
979 0 \
980 -c "client hello, adding alpn extension" \
981 -s "found alpn extension" \
982 -C "got an alert message, type: \\[2:120]" \
983 -s "server hello, adding alpn extension" \
984 -c "found alpn extension" \
985 -c "Application Layer Protocol is 1234" \
986 -s "Application Layer Protocol is 1234"
987
988run_test "ALPN #6 (both, no common)" \
989 "$P_SRV debug_level=4 alpn=abc,123" \
990 "$P_CLI debug_level=4 alpn=1234,abcde" \
991 1 \
992 -c "client hello, adding alpn extension" \
993 -s "found alpn extension" \
994 -c "got an alert message, type: \\[2:120]" \
995 -S "server hello, adding alpn extension" \
996 -C "found alpn extension" \
997 -C "Application Layer Protocol is 1234" \
998 -S "Application Layer Protocol is 1234"
999
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001000fi
1001
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001002# Tests for keyUsage in leaf certificates, part 1:
1003# server-side certificate/suite selection
1004
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001005run_test "keyUsage srv #1 (RSA, digitalSignature -> (EC)DHE-RSA)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001006 "$P_SRV key_file=data_files/server2.key \
1007 crt_file=data_files/server2.ku-ds.crt" \
1008 "$P_CLI" \
1009 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001010 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001011
1012
1013run_test "keyUsage srv #2 (RSA, keyEncipherment -> RSA)" \
1014 "$P_SRV key_file=data_files/server2.key \
1015 crt_file=data_files/server2.ku-ke.crt" \
1016 "$P_CLI" \
1017 0 \
1018 -c "Ciphersuite is TLS-RSA-WITH-"
1019
1020# add psk to leave an option for client to send SERVERQUIT
1021run_test "keyUsage srv #3 (RSA, keyAgreement -> fail)" \
1022 "$P_SRV psk=abc123 key_file=data_files/server2.key \
1023 crt_file=data_files/server2.ku-ka.crt" \
1024 "$P_CLI psk=badbad" \
1025 1 \
1026 -C "Ciphersuite is "
1027
1028run_test "keyUsage srv #4 (ECDSA, digitalSignature -> ECDHE-ECDSA)" \
1029 "$P_SRV key_file=data_files/server5.key \
1030 crt_file=data_files/server5.ku-ds.crt" \
1031 "$P_CLI" \
1032 0 \
1033 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1034
1035
1036run_test "keyUsage srv #5 (ECDSA, keyAgreement -> ECDH-)" \
1037 "$P_SRV key_file=data_files/server5.key \
1038 crt_file=data_files/server5.ku-ka.crt" \
1039 "$P_CLI" \
1040 0 \
1041 -c "Ciphersuite is TLS-ECDH-"
1042
1043# add psk to leave an option for client to send SERVERQUIT
1044run_test "keyUsage srv #6 (ECDSA, keyEncipherment -> fail)" \
1045 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1046 crt_file=data_files/server5.ku-ke.crt" \
1047 "$P_CLI psk=badbad" \
1048 1 \
1049 -C "Ciphersuite is "
1050
1051# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001052# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001053
1054run_test "keyUsage cli #1 (DigitalSignature+KeyEncipherment, RSA: OK)" \
1055 "$O_SRV -key data_files/server2.key \
1056 -cert data_files/server2.ku-ds_ke.crt" \
1057 "$P_CLI debug_level=2 \
1058 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1059 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001060 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001061 -C "Processing of the Certificate handshake message failed" \
1062 -c "Ciphersuite is TLS-"
1063
1064run_test "keyUsage cli #2 (DigitalSignature+KeyEncipherment, DHE-RSA: OK)" \
1065 "$O_SRV -key data_files/server2.key \
1066 -cert data_files/server2.ku-ds_ke.crt" \
1067 "$P_CLI debug_level=2 \
1068 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1069 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001070 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001071 -C "Processing of the Certificate handshake message failed" \
1072 -c "Ciphersuite is TLS-"
1073
1074run_test "keyUsage cli #3 (KeyEncipherment, RSA: OK)" \
1075 "$O_SRV -key data_files/server2.key \
1076 -cert data_files/server2.ku-ke.crt" \
1077 "$P_CLI debug_level=2 \
1078 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1079 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001080 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001081 -C "Processing of the Certificate handshake message failed" \
1082 -c "Ciphersuite is TLS-"
1083
1084run_test "keyUsage cli #4 (KeyEncipherment, DHE-RSA: fail)" \
1085 "$O_SRV -key data_files/server2.key \
1086 -cert data_files/server2.ku-ke.crt" \
1087 "$P_CLI debug_level=2 \
1088 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1089 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001090 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001091 -c "Processing of the Certificate handshake message failed" \
1092 -C "Ciphersuite is TLS-"
1093
1094run_test "keyUsage cli #5 (DigitalSignature, DHE-RSA: OK)" \
1095 "$O_SRV -key data_files/server2.key \
1096 -cert data_files/server2.ku-ds.crt" \
1097 "$P_CLI debug_level=2 \
1098 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1099 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001100 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001101 -C "Processing of the Certificate handshake message failed" \
1102 -c "Ciphersuite is TLS-"
1103
1104run_test "keyUsage cli #5 (DigitalSignature, RSA: fail)" \
1105 "$O_SRV -key data_files/server2.key \
1106 -cert data_files/server2.ku-ds.crt" \
1107 "$P_CLI debug_level=2 \
1108 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1109 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001110 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001111 -c "Processing of the Certificate handshake message failed" \
1112 -C "Ciphersuite is TLS-"
1113
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001114# Tests for keyUsage in leaf certificates, part 3:
1115# server-side checking of client cert
1116
1117run_test "keyUsage cli-auth #1 (RSA, DigitalSignature: OK)" \
1118 "$P_SRV debug_level=2 auth_mode=optional" \
1119 "$O_CLI -key data_files/server2.key \
1120 -cert data_files/server2.ku-ds.crt" \
1121 0 \
1122 -S "bad certificate (usage extensions)" \
1123 -S "Processing of the Certificate handshake message failed"
1124
1125run_test "keyUsage cli-auth #2 (RSA, KeyEncipherment: fail (soft))" \
1126 "$P_SRV debug_level=2 auth_mode=optional" \
1127 "$O_CLI -key data_files/server2.key \
1128 -cert data_files/server2.ku-ke.crt" \
1129 0 \
1130 -s "bad certificate (usage extensions)" \
1131 -S "Processing of the Certificate handshake message failed"
1132
1133run_test "keyUsage cli-auth #3 (RSA, KeyEncipherment: fail (hard))" \
1134 "$P_SRV debug_level=2 auth_mode=required" \
1135 "$O_CLI -key data_files/server2.key \
1136 -cert data_files/server2.ku-ke.crt" \
1137 1 \
1138 -s "bad certificate (usage extensions)" \
1139 -s "Processing of the Certificate handshake message failed"
1140
1141run_test "keyUsage cli-auth #4 (ECDSA, DigitalSignature: OK)" \
1142 "$P_SRV debug_level=2 auth_mode=optional" \
1143 "$O_CLI -key data_files/server5.key \
1144 -cert data_files/server5.ku-ds.crt" \
1145 0 \
1146 -S "bad certificate (usage extensions)" \
1147 -S "Processing of the Certificate handshake message failed"
1148
1149run_test "keyUsage cli-auth #5 (ECDSA, KeyAgreement: fail (soft))" \
1150 "$P_SRV debug_level=2 auth_mode=optional" \
1151 "$O_CLI -key data_files/server5.key \
1152 -cert data_files/server5.ku-ka.crt" \
1153 0 \
1154 -s "bad certificate (usage extensions)" \
1155 -S "Processing of the Certificate handshake message failed"
1156
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001157# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1158
1159run_test "extKeyUsage srv #1 (serverAuth -> OK)" \
1160 "$P_SRV key_file=data_files/server5.key \
1161 crt_file=data_files/server5.eku-srv.crt" \
1162 "$P_CLI" \
1163 0
1164
1165run_test "extKeyUsage srv #2 (serverAuth,clientAuth -> OK)" \
1166 "$P_SRV key_file=data_files/server5.key \
1167 crt_file=data_files/server5.eku-srv.crt" \
1168 "$P_CLI" \
1169 0
1170
1171run_test "extKeyUsage srv #3 (codeSign,anyEKU -> OK)" \
1172 "$P_SRV key_file=data_files/server5.key \
1173 crt_file=data_files/server5.eku-cs_any.crt" \
1174 "$P_CLI" \
1175 0
1176
1177# add psk to leave an option for client to send SERVERQUIT
1178run_test "extKeyUsage srv #4 (codeSign -> fail)" \
1179 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1180 crt_file=data_files/server5.eku-cli.crt" \
1181 "$P_CLI psk=badbad" \
1182 1
1183
1184# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1185
1186run_test "extKeyUsage cli #1 (serverAuth -> OK)" \
1187 "$O_SRV -key data_files/server5.key \
1188 -cert data_files/server5.eku-srv.crt" \
1189 "$P_CLI debug_level=2" \
1190 0 \
1191 -C "bad certificate (usage extensions)" \
1192 -C "Processing of the Certificate handshake message failed" \
1193 -c "Ciphersuite is TLS-"
1194
1195run_test "extKeyUsage cli #2 (serverAuth,clientAuth -> OK)" \
1196 "$O_SRV -key data_files/server5.key \
1197 -cert data_files/server5.eku-srv_cli.crt" \
1198 "$P_CLI debug_level=2" \
1199 0 \
1200 -C "bad certificate (usage extensions)" \
1201 -C "Processing of the Certificate handshake message failed" \
1202 -c "Ciphersuite is TLS-"
1203
1204run_test "extKeyUsage cli #3 (codeSign,anyEKU -> OK)" \
1205 "$O_SRV -key data_files/server5.key \
1206 -cert data_files/server5.eku-cs_any.crt" \
1207 "$P_CLI debug_level=2" \
1208 0 \
1209 -C "bad certificate (usage extensions)" \
1210 -C "Processing of the Certificate handshake message failed" \
1211 -c "Ciphersuite is TLS-"
1212
1213run_test "extKeyUsage cli #4 (codeSign -> fail)" \
1214 "$O_SRV -key data_files/server5.key \
1215 -cert data_files/server5.eku-cs.crt" \
1216 "$P_CLI debug_level=2" \
1217 1 \
1218 -c "bad certificate (usage extensions)" \
1219 -c "Processing of the Certificate handshake message failed" \
1220 -C "Ciphersuite is TLS-"
1221
1222# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1223
1224run_test "extKeyUsage cli-auth #1 (clientAuth -> OK)" \
1225 "$P_SRV debug_level=2 auth_mode=optional" \
1226 "$O_CLI -key data_files/server5.key \
1227 -cert data_files/server5.eku-cli.crt" \
1228 0 \
1229 -S "bad certificate (usage extensions)" \
1230 -S "Processing of the Certificate handshake message failed"
1231
1232run_test "extKeyUsage cli-auth #2 (serverAuth,clientAuth -> OK)" \
1233 "$P_SRV debug_level=2 auth_mode=optional" \
1234 "$O_CLI -key data_files/server5.key \
1235 -cert data_files/server5.eku-srv_cli.crt" \
1236 0 \
1237 -S "bad certificate (usage extensions)" \
1238 -S "Processing of the Certificate handshake message failed"
1239
1240run_test "extKeyUsage cli-auth #3 (codeSign,anyEKU -> OK)" \
1241 "$P_SRV debug_level=2 auth_mode=optional" \
1242 "$O_CLI -key data_files/server5.key \
1243 -cert data_files/server5.eku-cs_any.crt" \
1244 0 \
1245 -S "bad certificate (usage extensions)" \
1246 -S "Processing of the Certificate handshake message failed"
1247
1248run_test "extKeyUsage cli-auth #4 (codeSign -> fail (soft))" \
1249 "$P_SRV debug_level=2 auth_mode=optional" \
1250 "$O_CLI -key data_files/server5.key \
1251 -cert data_files/server5.eku-cs.crt" \
1252 0 \
1253 -s "bad certificate (usage extensions)" \
1254 -S "Processing of the Certificate handshake message failed"
1255
1256run_test "extKeyUsage cli-auth #4b (codeSign -> fail (hard))" \
1257 "$P_SRV debug_level=2 auth_mode=required" \
1258 "$O_CLI -key data_files/server5.key \
1259 -cert data_files/server5.eku-cs.crt" \
1260 1 \
1261 -s "bad certificate (usage extensions)" \
1262 -s "Processing of the Certificate handshake message failed"
1263
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001264# Final report
1265
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001266echo "------------------------------------------------------------------------"
1267
1268if [ $FAILS = 0 ]; then
1269 echo -n "PASSED"
1270else
1271 echo -n "FAILED"
1272fi
1273PASSES=`echo $TESTS - $FAILS | bc`
Manuel Pégourié-Gonnard4145b892014-02-24 13:20:14 +01001274echo " ($PASSES / $TESTS tests)"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001275
1276exit $FAILS