Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 1 | #!/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 | |
| 11 | PROGS_DIR='../programs/ssl' |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 12 | P_SRV="$PROGS_DIR/ssl_server2" |
| 13 | P_CLI="$PROGS_DIR/ssl_client2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 14 | |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 15 | TESTS=0 |
| 16 | FAILS=0 |
| 17 | |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 18 | # print_name <name> |
| 19 | print_name() { |
| 20 | echo -n "$1 " |
| 21 | LEN=`echo "$1" | wc -c` |
| 22 | LEN=`echo 72 - $LEN | bc` |
| 23 | for i in `seq 1 $LEN`; do echo -n '.'; done |
| 24 | echo -n ' ' |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 25 | |
| 26 | TESTS=`echo $TESTS + 1 | bc` |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | # fail <message> |
| 30 | fail() { |
| 31 | echo "FAIL" |
| 32 | echo " $1" |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 33 | |
| 34 | cp srv_out srv-${TESTS}.log |
| 35 | cp cli_out cli-${TESTS}.log |
| 36 | echo " outputs saved to srv-${TESTS}.log and cli-${TESTS}.log" |
| 37 | |
| 38 | FAILS=`echo $FAILS + 1 | bc` |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 39 | } |
| 40 | |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame^] | 41 | # is_polar <cmd_line> |
| 42 | is_polar() { |
| 43 | echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null |
| 44 | } |
| 45 | |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 46 | # Usage: run_test name srv_args cli_args cli_exit [option [...]] |
| 47 | # Options: -s pattern pattern that must be present in server output |
| 48 | # -c pattern pattern that must be present in client output |
| 49 | # -S pattern pattern that must be absent in server output |
| 50 | # -C pattern pattern that must be absent in client output |
| 51 | run_test() { |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 52 | print_name "$1" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 53 | shift |
| 54 | |
| 55 | # run the commands |
Manuel Pégourié-Gonnard | a9062e9 | 2014-02-25 16:21:22 +0100 | [diff] [blame] | 56 | $SHELL -c "$1" > srv_out 2>&1 & |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 57 | SRV_PID=$! |
| 58 | sleep 1 |
Manuel Pégourié-Gonnard | a9062e9 | 2014-02-25 16:21:22 +0100 | [diff] [blame] | 59 | $SHELL -c "$2" > cli_out 2>&1 |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 60 | CLI_EXIT=$? |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame^] | 61 | if is_polar $2; then |
| 62 | echo SERVERQUIT | openssl s_client -no_ticket \ |
| 63 | -cert data_files/cli2.crt -key data_files/cli2.key \ |
| 64 | >/dev/null 2>&1 |
| 65 | else |
| 66 | kill $SRV_PID |
| 67 | fi |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 68 | wait $SRV_PID |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame^] | 69 | |
| 70 | # check if the client and server went at least to the handshake stage |
| 71 | # (usefull to avoid tests with only negative assertions and non-zero |
| 72 | # expected client exit to incorrectly succeed in case of catastrophic |
| 73 | # failure) |
| 74 | if is_polar $1; then |
| 75 | if grep "Performing the SSL/TLS handshake" srv_out >/dev/null; then :; |
| 76 | else |
| 77 | fail "server failed to start" |
| 78 | return |
| 79 | fi |
| 80 | fi |
| 81 | if is_polar $2; then |
| 82 | if grep "Performing the SSL/TLS handshake" cli_out >/dev/null; then :; |
| 83 | else |
| 84 | fail "client failed to start" |
| 85 | return |
| 86 | fi |
| 87 | fi |
| 88 | |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 89 | shift 2 |
| 90 | |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 91 | # check server exit code |
| 92 | if [ $? != 0 ]; then |
| 93 | fail "server fail" |
| 94 | return |
| 95 | fi |
| 96 | |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 97 | # check client exit code |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 98 | if [ \( "$1" = 0 -a "$CLI_EXIT" != 0 \) -o \ |
| 99 | \( "$1" != 0 -a "$CLI_EXIT" = 0 \) ] |
| 100 | then |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 101 | fail "bad client exit code" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 102 | return |
| 103 | fi |
| 104 | shift |
| 105 | |
| 106 | # check options |
| 107 | while [ $# -gt 0 ] |
| 108 | do |
| 109 | case $1 in |
| 110 | "-s") |
| 111 | if grep "$2" srv_out >/dev/null; then :; else |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 112 | fail "-s $2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 113 | return |
| 114 | fi |
| 115 | ;; |
| 116 | |
| 117 | "-c") |
| 118 | if grep "$2" cli_out >/dev/null; then :; else |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 119 | fail "-c $2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 120 | return |
| 121 | fi |
| 122 | ;; |
| 123 | |
| 124 | "-S") |
| 125 | if grep "$2" srv_out >/dev/null; then |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 126 | fail "-S $2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 127 | return |
| 128 | fi |
| 129 | ;; |
| 130 | |
| 131 | "-C") |
| 132 | if grep "$2" cli_out >/dev/null; then |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 133 | fail "-C $2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 134 | return |
| 135 | fi |
| 136 | ;; |
| 137 | |
| 138 | *) |
| 139 | echo "Unkown test: $1" >&2 |
| 140 | exit 1 |
| 141 | esac |
| 142 | shift 2 |
| 143 | done |
| 144 | |
| 145 | # if we're here, everything is ok |
| 146 | echo "PASS" |
| 147 | rm -r srv_out cli_out |
| 148 | } |
| 149 | |
Manuel Pégourié-Gonnard | a9062e9 | 2014-02-25 16:21:22 +0100 | [diff] [blame] | 150 | cleanup() { |
| 151 | kill $SRV_PID |
| 152 | exit 1 |
| 153 | } |
| 154 | |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 155 | killall -q openssl ssl_server ssl_server2 |
Manuel Pégourié-Gonnard | a9062e9 | 2014-02-25 16:21:22 +0100 | [diff] [blame] | 156 | trap cleanup INT TERM HUP |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 157 | |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 158 | # Test for SSLv2 ClientHello |
| 159 | |
| 160 | run_test "SSLv2 ClientHello #0 (reference)" \ |
| 161 | "$P_SRV debug_level=3" \ |
| 162 | "echo GET / HTTP/1.0 | openssl s_client -no_ssl2" \ |
| 163 | 0 \ |
| 164 | -S "parse client hello v2" \ |
| 165 | -S "ssl_handshake returned" |
| 166 | |
| 167 | # Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello |
| 168 | run_test "SSLv2 ClientHello #1 (actual test)" \ |
| 169 | "$P_SRV debug_level=3" \ |
| 170 | "echo GET / HTTP/1.0 | openssl s_client -cipher DES-CBC-MD5:ALL" \ |
| 171 | 0 \ |
| 172 | -s "parse client hello v2" \ |
| 173 | -S "ssl_handshake returned" |
| 174 | |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 175 | # Tests for Truncated HMAC extension |
| 176 | |
| 177 | run_test "Truncated HMAC #0" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 178 | "$P_SRV debug_level=5" \ |
| 179 | "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 180 | 0 \ |
| 181 | -s "dumping 'computed mac' (20 bytes)" |
| 182 | |
| 183 | run_test "Truncated HMAC #1" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 184 | "$P_SRV debug_level=5" \ |
| 185 | "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 186 | 0 \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 187 | -s "dumping 'computed mac' (10 bytes)" |
| 188 | |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 189 | # Tests for Session Tickets |
| 190 | |
Manuel Pégourié-Gonnard | 4c88345 | 2014-02-20 21:32:41 +0100 | [diff] [blame] | 191 | run_test "Session resume using tickets #1" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 192 | "$P_SRV debug_level=4 tickets=1" \ |
| 193 | "$P_CLI debug_level=4 tickets=1 reconnect=1" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 194 | 0 \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 195 | -c "client hello, adding session ticket extension" \ |
| 196 | -s "found session ticket extension" \ |
| 197 | -s "server hello, adding session ticket extension" \ |
| 198 | -c "found session_ticket extension" \ |
| 199 | -c "parse new session ticket" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 200 | -S "session successfully restored from cache" \ |
| 201 | -s "session successfully restored from ticket" \ |
| 202 | -s "a session has been resumed" \ |
| 203 | -c "a session has been resumed" |
| 204 | |
Manuel Pégourié-Gonnard | 4c88345 | 2014-02-20 21:32:41 +0100 | [diff] [blame] | 205 | run_test "Session resume using tickets #2" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 206 | "$P_SRV debug_level=4 tickets=1 cache_max=0" \ |
| 207 | "$P_CLI debug_level=4 tickets=1 reconnect=1" \ |
Manuel Pégourié-Gonnard | dbe1ee1 | 2014-02-21 09:18:13 +0100 | [diff] [blame] | 208 | 0 \ |
| 209 | -c "client hello, adding session ticket extension" \ |
| 210 | -s "found session ticket extension" \ |
| 211 | -s "server hello, adding session ticket extension" \ |
| 212 | -c "found session_ticket extension" \ |
| 213 | -c "parse new session ticket" \ |
| 214 | -S "session successfully restored from cache" \ |
| 215 | -s "session successfully restored from ticket" \ |
| 216 | -s "a session has been resumed" \ |
| 217 | -c "a session has been resumed" |
| 218 | |
| 219 | run_test "Session resume using tickets #3" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 220 | "$P_SRV debug_level=4 tickets=1 cache_max=0 ticket_timeout=1" \ |
| 221 | "$P_CLI debug_level=4 tickets=1 reconnect=1 reco_delay=2" \ |
Manuel Pégourié-Gonnard | dbe1ee1 | 2014-02-21 09:18:13 +0100 | [diff] [blame] | 222 | 0 \ |
| 223 | -c "client hello, adding session ticket extension" \ |
| 224 | -s "found session ticket extension" \ |
| 225 | -s "server hello, adding session ticket extension" \ |
| 226 | -c "found session_ticket extension" \ |
| 227 | -c "parse new session ticket" \ |
| 228 | -S "session successfully restored from cache" \ |
| 229 | -S "session successfully restored from ticket" \ |
| 230 | -S "a session has been resumed" \ |
| 231 | -C "a session has been resumed" |
| 232 | |
| 233 | run_test "Session resume using tickets #4" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 234 | "$P_SRV debug_level=4 tickets=1 cache_max=0 ticket_timeout=2" \ |
| 235 | "$P_CLI debug_level=4 tickets=1 reconnect=1 reco_delay=0" \ |
Manuel Pégourié-Gonnard | 4c88345 | 2014-02-20 21:32:41 +0100 | [diff] [blame] | 236 | 0 \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 237 | -c "client hello, adding session ticket extension" \ |
| 238 | -s "found session ticket extension" \ |
| 239 | -s "server hello, adding session ticket extension" \ |
| 240 | -c "found session_ticket extension" \ |
| 241 | -c "parse new session ticket" \ |
Manuel Pégourié-Gonnard | 4c88345 | 2014-02-20 21:32:41 +0100 | [diff] [blame] | 242 | -S "session successfully restored from cache" \ |
| 243 | -s "session successfully restored from ticket" \ |
| 244 | -s "a session has been resumed" \ |
| 245 | -c "a session has been resumed" |
| 246 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 247 | # Tests for Session Resume based on session-ID and cache |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 248 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 249 | run_test "Session resume using cache #1 (tickets enabled on client)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 250 | "$P_SRV debug_level=4 tickets=0" \ |
| 251 | "$P_CLI debug_level=4 tickets=1 reconnect=1" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 252 | 0 \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 253 | -c "client hello, adding session ticket extension" \ |
| 254 | -s "found session ticket extension" \ |
| 255 | -S "server hello, adding session ticket extension" \ |
| 256 | -C "found session_ticket extension" \ |
| 257 | -C "parse new session ticket" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 258 | -s "session successfully restored from cache" \ |
| 259 | -S "session successfully restored from ticket" \ |
| 260 | -s "a session has been resumed" \ |
| 261 | -c "a session has been resumed" |
| 262 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 263 | run_test "Session resume using cache #2 (tickets enabled on server)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 264 | "$P_SRV debug_level=4 tickets=1" \ |
| 265 | "$P_CLI debug_level=4 tickets=0 reconnect=1" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 266 | 0 \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 267 | -C "client hello, adding session ticket extension" \ |
| 268 | -S "found session ticket extension" \ |
| 269 | -S "server hello, adding session ticket extension" \ |
| 270 | -C "found session_ticket extension" \ |
| 271 | -C "parse new session ticket" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 272 | -s "session successfully restored from cache" \ |
| 273 | -S "session successfully restored from ticket" \ |
| 274 | -s "a session has been resumed" \ |
| 275 | -c "a session has been resumed" |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 276 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 277 | run_test "Session resume using cache #3 (cache_max=0)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 278 | "$P_SRV debug_level=4 tickets=0 cache_max=0" \ |
| 279 | "$P_CLI debug_level=4 tickets=0 reconnect=1" \ |
Manuel Pégourié-Gonnard | 4c88345 | 2014-02-20 21:32:41 +0100 | [diff] [blame] | 280 | 0 \ |
| 281 | -S "session successfully restored from cache" \ |
| 282 | -S "session successfully restored from ticket" \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 283 | -S "a session has been resumed" \ |
| 284 | -C "a session has been resumed" |
Manuel Pégourié-Gonnard | 4c88345 | 2014-02-20 21:32:41 +0100 | [diff] [blame] | 285 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 286 | run_test "Session resume using cache #4 (cache_max=1)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 287 | "$P_SRV debug_level=4 tickets=0 cache_max=1" \ |
| 288 | "$P_CLI debug_level=4 tickets=0 reconnect=1" \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 289 | 0 \ |
| 290 | -s "session successfully restored from cache" \ |
| 291 | -S "session successfully restored from ticket" \ |
| 292 | -s "a session has been resumed" \ |
| 293 | -c "a session has been resumed" |
| 294 | |
| 295 | run_test "Session resume using cache #5 (timemout > delay)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 296 | "$P_SRV debug_level=4 tickets=0 cache_timeout=1" \ |
| 297 | "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=0" \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 298 | 0 \ |
| 299 | -s "session successfully restored from cache" \ |
| 300 | -S "session successfully restored from ticket" \ |
| 301 | -s "a session has been resumed" \ |
| 302 | -c "a session has been resumed" |
| 303 | |
| 304 | run_test "Session resume using cache #6 (timeout < delay)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 305 | "$P_SRV debug_level=4 tickets=0 cache_timeout=1" \ |
| 306 | "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 307 | 0 \ |
| 308 | -S "session successfully restored from cache" \ |
| 309 | -S "session successfully restored from ticket" \ |
| 310 | -S "a session has been resumed" \ |
| 311 | -C "a session has been resumed" |
| 312 | |
| 313 | run_test "Session resume using cache #7 (no timeout)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 314 | "$P_SRV debug_level=4 tickets=0 cache_timeout=0" \ |
| 315 | "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \ |
Manuel Pégourié-Gonnard | 4c88345 | 2014-02-20 21:32:41 +0100 | [diff] [blame] | 316 | 0 \ |
| 317 | -s "session successfully restored from cache" \ |
| 318 | -S "session successfully restored from ticket" \ |
| 319 | -s "a session has been resumed" \ |
| 320 | -c "a session has been resumed" |
| 321 | |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 322 | # Tests for Max Fragment Length extension |
| 323 | |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 324 | run_test "Max fragment length #1" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 325 | "$P_SRV debug_level=4" \ |
| 326 | "$P_CLI debug_level=4" \ |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 327 | 0 \ |
| 328 | -C "client hello, adding max_fragment_length extension" \ |
| 329 | -S "found max fragment length extension" \ |
| 330 | -S "server hello, max_fragment_length extension" \ |
| 331 | -C "found max_fragment_length extension" |
| 332 | |
| 333 | run_test "Max fragment length #2" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 334 | "$P_SRV debug_level=4" \ |
| 335 | "$P_CLI debug_level=4 max_frag_len=4096" \ |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 336 | 0 \ |
| 337 | -c "client hello, adding max_fragment_length extension" \ |
| 338 | -s "found max fragment length extension" \ |
| 339 | -s "server hello, max_fragment_length extension" \ |
| 340 | -c "found max_fragment_length extension" |
| 341 | |
| 342 | run_test "Max fragment length #3" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 343 | "$P_SRV debug_level=4 max_frag_len=4096" \ |
| 344 | "$P_CLI debug_level=4" \ |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 345 | 0 \ |
| 346 | -C "client hello, adding max_fragment_length extension" \ |
| 347 | -S "found max fragment length extension" \ |
| 348 | -S "server hello, max_fragment_length extension" \ |
| 349 | -C "found max_fragment_length extension" |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 350 | |
| 351 | # Tests for renegotiation |
| 352 | |
| 353 | run_test "Renegotiation #0 (none)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 354 | "$P_SRV debug_level=4" \ |
| 355 | "$P_CLI debug_level=4" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 356 | 0 \ |
| 357 | -C "client hello, adding renegotiation extension" \ |
| 358 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 359 | -S "found renegotiation extension" \ |
| 360 | -s "server hello, secure renegotiation extension" \ |
| 361 | -c "found renegotiation extension" \ |
| 362 | -C "renegotiate" \ |
| 363 | -S "renegotiate" \ |
| 364 | -S "write hello request" |
| 365 | |
| 366 | run_test "Renegotiation #1 (enabled, client-initiated)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 367 | "$P_SRV debug_level=4" \ |
| 368 | "$P_CLI debug_level=4 renegotiate=1" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 369 | 0 \ |
| 370 | -c "client hello, adding renegotiation extension" \ |
| 371 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 372 | -s "found renegotiation extension" \ |
| 373 | -s "server hello, secure renegotiation extension" \ |
| 374 | -c "found renegotiation extension" \ |
| 375 | -c "renegotiate" \ |
| 376 | -s "renegotiate" \ |
| 377 | -S "write hello request" |
| 378 | |
| 379 | run_test "Renegotiation #2 (enabled, server-initiated)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 380 | "$P_SRV debug_level=4 renegotiate=1" \ |
| 381 | "$P_CLI debug_level=4" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 382 | 0 \ |
| 383 | -c "client hello, adding renegotiation extension" \ |
| 384 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 385 | -s "found renegotiation extension" \ |
| 386 | -s "server hello, secure renegotiation extension" \ |
| 387 | -c "found renegotiation extension" \ |
| 388 | -c "renegotiate" \ |
| 389 | -s "renegotiate" \ |
| 390 | -s "write hello request" |
| 391 | |
| 392 | run_test "Renegotiation #3 (enabled, double)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 393 | "$P_SRV debug_level=4 renegotiate=1" \ |
| 394 | "$P_CLI debug_level=4 renegotiate=1" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 395 | 0 \ |
| 396 | -c "client hello, adding renegotiation extension" \ |
| 397 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 398 | -s "found renegotiation extension" \ |
| 399 | -s "server hello, secure renegotiation extension" \ |
| 400 | -c "found renegotiation extension" \ |
| 401 | -c "renegotiate" \ |
| 402 | -s "renegotiate" \ |
| 403 | -s "write hello request" |
| 404 | |
| 405 | run_test "Renegotiation #4 (client-initiated, server-rejected)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 406 | "$P_SRV debug_level=4 renegotiation=0" \ |
| 407 | "$P_CLI debug_level=4 renegotiate=1" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 408 | 1 \ |
| 409 | -c "client hello, adding renegotiation extension" \ |
| 410 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 411 | -S "found renegotiation extension" \ |
| 412 | -s "server hello, secure renegotiation extension" \ |
| 413 | -c "found renegotiation extension" \ |
| 414 | -c "renegotiate" \ |
| 415 | -S "renegotiate" \ |
| 416 | -S "write hello request" |
| 417 | |
| 418 | run_test "Renegotiation #5 (server-initiated, client-rejected)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 419 | "$P_SRV debug_level=4 renegotiate=1" \ |
| 420 | "$P_CLI debug_level=4 renegotiation=0" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 421 | 0 \ |
| 422 | -C "client hello, adding renegotiation extension" \ |
| 423 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 424 | -S "found renegotiation extension" \ |
| 425 | -s "server hello, secure renegotiation extension" \ |
| 426 | -c "found renegotiation extension" \ |
| 427 | -C "renegotiate" \ |
| 428 | -S "renegotiate" \ |
| 429 | -s "write hello request" \ |
| 430 | -s "SSL - An unexpected message was received from our peer" \ |
| 431 | -s "failed" |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 432 | |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 433 | # Tests for auth_mode |
| 434 | |
| 435 | run_test "Authentication #1 (server badcert, client required)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 436 | "$P_SRV crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 437 | key_file=data_files/server5.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 438 | "$P_CLI debug_level=2 auth_mode=required" \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 439 | 1 \ |
| 440 | -c "x509_verify_cert() returned" \ |
| 441 | -c "! self-signed or not signed by a trusted CA" \ |
| 442 | -c "! ssl_handshake returned" \ |
| 443 | -c "X509 - Certificate verification failed" |
| 444 | |
| 445 | run_test "Authentication #2 (server badcert, client optional)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 446 | "$P_SRV crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 447 | key_file=data_files/server5.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 448 | "$P_CLI debug_level=2 auth_mode=optional" \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 449 | 0 \ |
| 450 | -c "x509_verify_cert() returned" \ |
| 451 | -c "! self-signed or not signed by a trusted CA" \ |
| 452 | -C "! ssl_handshake returned" \ |
| 453 | -C "X509 - Certificate verification failed" |
| 454 | |
| 455 | run_test "Authentication #3 (server badcert, client none)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 456 | "$P_SRV crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 457 | key_file=data_files/server5.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 458 | "$P_CLI debug_level=2 auth_mode=none" \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 459 | 0 \ |
| 460 | -C "x509_verify_cert() returned" \ |
| 461 | -C "! self-signed or not signed by a trusted CA" \ |
| 462 | -C "! ssl_handshake returned" \ |
| 463 | -C "X509 - Certificate verification failed" |
| 464 | |
| 465 | run_test "Authentication #4 (client badcert, server required)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 466 | "$P_SRV debug_level=4 auth_mode=required" \ |
| 467 | "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 468 | key_file=data_files/server5.key" \ |
| 469 | 1 \ |
| 470 | -S "skip write certificate request" \ |
| 471 | -C "skip parse certificate request" \ |
| 472 | -c "got a certificate request" \ |
| 473 | -C "skip write certificate" \ |
| 474 | -C "skip write certificate verify" \ |
| 475 | -S "skip parse certificate verify" \ |
| 476 | -s "x509_verify_cert() returned" \ |
| 477 | -S "! self-signed or not signed by a trusted CA" \ |
| 478 | -s "! ssl_handshake returned" \ |
| 479 | -c "! ssl_handshake returned" \ |
| 480 | -s "X509 - Certificate verification failed" |
| 481 | |
| 482 | run_test "Authentication #5 (client badcert, server optional)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 483 | "$P_SRV debug_level=4 auth_mode=optional" \ |
| 484 | "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 485 | key_file=data_files/server5.key" \ |
| 486 | 0 \ |
| 487 | -S "skip write certificate request" \ |
| 488 | -C "skip parse certificate request" \ |
| 489 | -c "got a certificate request" \ |
| 490 | -C "skip write certificate" \ |
| 491 | -C "skip write certificate verify" \ |
| 492 | -S "skip parse certificate verify" \ |
| 493 | -s "x509_verify_cert() returned" \ |
| 494 | -s "! self-signed or not signed by a trusted CA" \ |
| 495 | -S "! ssl_handshake returned" \ |
| 496 | -C "! ssl_handshake returned" \ |
| 497 | -S "X509 - Certificate verification failed" |
| 498 | |
| 499 | run_test "Authentication #6 (client badcert, server none)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 500 | "$P_SRV debug_level=4 auth_mode=none" \ |
| 501 | "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 502 | key_file=data_files/server5.key" \ |
| 503 | 0 \ |
| 504 | -s "skip write certificate request" \ |
| 505 | -C "skip parse certificate request" \ |
| 506 | -c "got no certificate request" \ |
| 507 | -c "skip write certificate" \ |
| 508 | -c "skip write certificate verify" \ |
| 509 | -s "skip parse certificate verify" \ |
| 510 | -S "x509_verify_cert() returned" \ |
| 511 | -S "! self-signed or not signed by a trusted CA" \ |
| 512 | -S "! ssl_handshake returned" \ |
| 513 | -C "! ssl_handshake returned" \ |
| 514 | -S "X509 - Certificate verification failed" |
| 515 | |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 516 | # tests for SNI |
| 517 | |
| 518 | run_test "SNI #0 (no SNI callback)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 519 | "$P_SRV debug_level=4 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 520 | crt_file=data_files/server5.crt key_file=data_files/server5.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 521 | "$P_CLI debug_level=0 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 522 | server_name=localhost" \ |
| 523 | 0 \ |
| 524 | -S "parse ServerName extension" \ |
| 525 | -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \ |
| 526 | -c "subject name *: C=NL, O=PolarSSL, CN=localhost" |
| 527 | |
| 528 | run_test "SNI #1 (matching cert 1)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 529 | "$P_SRV debug_level=4 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 530 | crt_file=data_files/server5.crt key_file=data_files/server5.key \ |
| 531 | sni='localhost,data_files/server2.crt,data_files/server2.key,PolarSSL Server 1,data_files/server1.crt,data_files/server1.key'" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 532 | "$P_CLI debug_level=0 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 533 | server_name=localhost" \ |
| 534 | 0 \ |
| 535 | -s "parse ServerName extension" \ |
| 536 | -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \ |
| 537 | -c "subject name *: C=NL, O=PolarSSL, CN=localhost" |
| 538 | |
| 539 | run_test "SNI #2 (matching cert 2)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 540 | "$P_SRV debug_level=4 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 541 | crt_file=data_files/server5.crt key_file=data_files/server5.key \ |
| 542 | sni='localhost,data_files/server2.crt,data_files/server2.key,PolarSSL Server 1,data_files/server1.crt,data_files/server1.key'" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 543 | "$P_CLI debug_level=0 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 544 | server_name='PolarSSL Server 1'" \ |
| 545 | 0 \ |
| 546 | -s "parse ServerName extension" \ |
| 547 | -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \ |
| 548 | -c "subject name *: C=NL, O=PolarSSL, CN=PolarSSL Server 1" |
| 549 | |
| 550 | run_test "SNI #3 (no matching cert)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 551 | "$P_SRV debug_level=4 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 552 | crt_file=data_files/server5.crt key_file=data_files/server5.key \ |
| 553 | sni='localhost,data_files/server2.crt,data_files/server2.key,PolarSSL Server 1,data_files/server1.crt,data_files/server1.key'" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 554 | "$P_CLI debug_level=0 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 555 | server_name='PolarSSL Server 2'" \ |
| 556 | 1 \ |
| 557 | -s "parse ServerName extension" \ |
| 558 | -s "ssl_sni_wrapper() returned" \ |
| 559 | -s "ssl_handshake returned" \ |
| 560 | -c "ssl_handshake returned" \ |
| 561 | -c "SSL - A fatal alert message was received from our peer" |
| 562 | |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 563 | # Final report |
| 564 | |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 565 | echo "------------------------------------------------------------------------" |
| 566 | |
| 567 | if [ $FAILS = 0 ]; then |
| 568 | echo -n "PASSED" |
| 569 | else |
| 570 | echo -n "FAILED" |
| 571 | fi |
| 572 | PASSES=`echo $TESTS - $FAILS | bc` |
Manuel Pégourié-Gonnard | 4145b89 | 2014-02-24 13:20:14 +0100 | [diff] [blame] | 573 | echo " ($PASSES / $TESTS tests)" |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 574 | |
| 575 | exit $FAILS |