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 | |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 11 | set -u |
| 12 | |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 13 | PROGS_DIR='../programs/ssl' |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 14 | P_SRV="$PROGS_DIR/ssl_server2 server_addr=0.0.0.0" # force IPv4 for OpenSSL |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 15 | P_CLI="$PROGS_DIR/ssl_client2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 16 | |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 17 | O_ARGS="-www -cert data_files/server5.crt -key data_files/server5.key" |
| 18 | O_CLI="echo 'GET / HTTP/1.0' | openssl s_client" |
| 19 | |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 20 | TESTS=0 |
| 21 | FAILS=0 |
| 22 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 23 | MEMCHECK=0 |
| 24 | |
| 25 | print_usage() { |
| 26 | echo "Usage: $0 [options]" |
| 27 | echo -e " -h, --help\tPrint this help." |
| 28 | echo -e " -m, --memcheck\tCheck memory leaks." |
| 29 | } |
| 30 | |
| 31 | get_options() { |
| 32 | while [ $# -gt 0 ]; do |
| 33 | case "$1" in |
| 34 | -m|--memcheck) |
| 35 | MEMCHECK=1 |
| 36 | ;; |
| 37 | -h|--help) |
| 38 | print_usage |
| 39 | exit 0 |
| 40 | ;; |
| 41 | *) |
| 42 | echo "Unkown argument: '$1'" |
| 43 | print_usage |
| 44 | exit 1 |
| 45 | ;; |
| 46 | esac |
| 47 | shift |
| 48 | done |
| 49 | } |
| 50 | |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 51 | # print_name <name> |
| 52 | print_name() { |
| 53 | echo -n "$1 " |
| 54 | LEN=`echo "$1" | wc -c` |
| 55 | LEN=`echo 72 - $LEN | bc` |
| 56 | for i in `seq 1 $LEN`; do echo -n '.'; done |
| 57 | echo -n ' ' |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 58 | |
| 59 | TESTS=`echo $TESTS + 1 | bc` |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | # fail <message> |
| 63 | fail() { |
| 64 | echo "FAIL" |
| 65 | echo " $1" |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 66 | |
| 67 | cp srv_out srv-${TESTS}.log |
| 68 | cp cli_out cli-${TESTS}.log |
| 69 | echo " outputs saved to srv-${TESTS}.log and cli-${TESTS}.log" |
| 70 | |
| 71 | FAILS=`echo $FAILS + 1 | bc` |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 72 | } |
| 73 | |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame] | 74 | # is_polar <cmd_line> |
| 75 | is_polar() { |
| 76 | echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null |
| 77 | } |
| 78 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 79 | # has_mem_err <log_file_name> |
| 80 | has_mem_err() { |
| 81 | if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" && |
| 82 | grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null |
| 83 | then |
| 84 | return 1 # false: does not have errors |
| 85 | else |
| 86 | return 0 # true: has errors |
| 87 | fi |
| 88 | } |
| 89 | |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 90 | # Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]] |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 91 | # Options: -s pattern pattern that must be present in server output |
| 92 | # -c pattern pattern that must be present in client output |
| 93 | # -S pattern pattern that must be absent in server output |
| 94 | # -C pattern pattern that must be absent in client output |
| 95 | run_test() { |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 96 | NAME="$1" |
| 97 | SRV_CMD="$2" |
| 98 | CLI_CMD="$3" |
| 99 | CLI_EXPECT="$4" |
| 100 | shift 4 |
| 101 | |
| 102 | print_name "$NAME" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 103 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 104 | # prepend valgrind to our commands if active |
| 105 | if [ "$MEMCHECK" -gt 0 ]; then |
| 106 | if is_polar "$SRV_CMD"; then |
| 107 | SRV_CMD="valgrind --leak-check=full $SRV_CMD" |
| 108 | fi |
| 109 | if is_polar "$CLI_CMD"; then |
| 110 | CLI_CMD="valgrind --leak-check=full $CLI_CMD" |
| 111 | fi |
| 112 | fi |
| 113 | |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 114 | # run the commands |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 115 | $SHELL -c "$SRV_CMD" > srv_out 2>&1 & |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 116 | SRV_PID=$! |
| 117 | sleep 1 |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 118 | $SHELL -c "$CLI_CMD" > cli_out 2>&1 |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 119 | CLI_EXIT=$? |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 120 | if is_polar "$SRV_CMD"; then |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame] | 121 | echo SERVERQUIT | openssl s_client -no_ticket \ |
| 122 | -cert data_files/cli2.crt -key data_files/cli2.key \ |
| 123 | >/dev/null 2>&1 |
| 124 | else |
| 125 | kill $SRV_PID |
| 126 | fi |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 127 | wait $SRV_PID |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame] | 128 | |
| 129 | # check if the client and server went at least to the handshake stage |
| 130 | # (usefull to avoid tests with only negative assertions and non-zero |
| 131 | # expected client exit to incorrectly succeed in case of catastrophic |
| 132 | # failure) |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 133 | if is_polar "$SRV_CMD"; then |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame] | 134 | if grep "Performing the SSL/TLS handshake" srv_out >/dev/null; then :; |
| 135 | else |
| 136 | fail "server failed to start" |
| 137 | return |
| 138 | fi |
| 139 | fi |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 140 | if is_polar "$CLI_CMD"; then |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame] | 141 | if grep "Performing the SSL/TLS handshake" cli_out >/dev/null; then :; |
| 142 | else |
| 143 | fail "client failed to start" |
| 144 | return |
| 145 | fi |
| 146 | fi |
| 147 | |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 148 | # check server exit code |
| 149 | if [ $? != 0 ]; then |
| 150 | fail "server fail" |
| 151 | return |
| 152 | fi |
| 153 | |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 154 | # check client exit code |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 155 | if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \ |
| 156 | \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ] |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 157 | then |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 158 | fail "bad client exit code" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 159 | return |
| 160 | fi |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 161 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 162 | # check other assertions |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 163 | while [ $# -gt 0 ] |
| 164 | do |
| 165 | case $1 in |
| 166 | "-s") |
| 167 | if grep "$2" srv_out >/dev/null; then :; else |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 168 | fail "-s $2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 169 | return |
| 170 | fi |
| 171 | ;; |
| 172 | |
| 173 | "-c") |
| 174 | if grep "$2" cli_out >/dev/null; then :; else |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 175 | fail "-c $2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 176 | return |
| 177 | fi |
| 178 | ;; |
| 179 | |
| 180 | "-S") |
| 181 | if grep "$2" srv_out >/dev/null; then |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 182 | fail "-S $2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 183 | return |
| 184 | fi |
| 185 | ;; |
| 186 | |
| 187 | "-C") |
| 188 | if grep "$2" cli_out >/dev/null; then |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 189 | fail "-C $2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 190 | return |
| 191 | fi |
| 192 | ;; |
| 193 | |
| 194 | *) |
| 195 | echo "Unkown test: $1" >&2 |
| 196 | exit 1 |
| 197 | esac |
| 198 | shift 2 |
| 199 | done |
| 200 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 201 | # check valgrind's results |
| 202 | if [ "$MEMCHECK" -gt 0 ]; then |
| 203 | if is_polar "$SRV_CMD" && has_mem_err srv_out; then |
| 204 | fail "Server has memory errors" |
| 205 | return |
| 206 | fi |
| 207 | if is_polar "$CLI_CMD" && has_mem_err cli_out; then |
| 208 | fail "Client has memory errors" |
| 209 | return |
| 210 | fi |
| 211 | fi |
| 212 | |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 213 | # if we're here, everything is ok |
| 214 | echo "PASS" |
Manuel Pégourié-Gonnard | a3d808e | 2014-02-26 16:33:03 +0100 | [diff] [blame] | 215 | rm -f srv_out cli_out |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 216 | } |
| 217 | |
Manuel Pégourié-Gonnard | a9062e9 | 2014-02-25 16:21:22 +0100 | [diff] [blame] | 218 | cleanup() { |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 219 | rm -f cli_out srv_out sess |
Manuel Pégourié-Gonnard | a9062e9 | 2014-02-25 16:21:22 +0100 | [diff] [blame] | 220 | kill $SRV_PID |
| 221 | exit 1 |
| 222 | } |
| 223 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 224 | get_options "$@" |
| 225 | |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 226 | killall -q openssl ssl_server ssl_server2 |
Manuel Pégourié-Gonnard | a9062e9 | 2014-02-25 16:21:22 +0100 | [diff] [blame] | 227 | trap cleanup INT TERM HUP |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 228 | |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 229 | # Test for SSLv2 ClientHello |
| 230 | |
| 231 | run_test "SSLv2 ClientHello #0 (reference)" \ |
| 232 | "$P_SRV debug_level=3" \ |
Manuel Pégourié-Gonnard | a3d808e | 2014-02-26 16:33:03 +0100 | [diff] [blame] | 233 | "$O_CLI -no_ssl2" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 234 | 0 \ |
| 235 | -S "parse client hello v2" \ |
| 236 | -S "ssl_handshake returned" |
| 237 | |
| 238 | # Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello |
| 239 | run_test "SSLv2 ClientHello #1 (actual test)" \ |
| 240 | "$P_SRV debug_level=3" \ |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 241 | "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 242 | 0 \ |
| 243 | -s "parse client hello v2" \ |
| 244 | -S "ssl_handshake returned" |
| 245 | |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 246 | # Tests for Truncated HMAC extension |
| 247 | |
| 248 | run_test "Truncated HMAC #0" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 249 | "$P_SRV debug_level=5" \ |
| 250 | "$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] | 251 | 0 \ |
| 252 | -s "dumping 'computed mac' (20 bytes)" |
| 253 | |
| 254 | run_test "Truncated HMAC #1" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 255 | "$P_SRV debug_level=5" \ |
| 256 | "$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] | 257 | 0 \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 258 | -s "dumping 'computed mac' (10 bytes)" |
| 259 | |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 260 | # Tests for Session Tickets |
| 261 | |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 262 | run_test "Session resume using tickets #1 (basic)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 263 | "$P_SRV debug_level=4 tickets=1" \ |
| 264 | "$P_CLI debug_level=4 tickets=1 reconnect=1" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 265 | 0 \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 266 | -c "client hello, adding session ticket extension" \ |
| 267 | -s "found session ticket extension" \ |
| 268 | -s "server hello, adding session ticket extension" \ |
| 269 | -c "found session_ticket extension" \ |
| 270 | -c "parse new session ticket" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 271 | -S "session successfully restored from cache" \ |
| 272 | -s "session successfully restored from ticket" \ |
| 273 | -s "a session has been resumed" \ |
| 274 | -c "a session has been resumed" |
| 275 | |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 276 | run_test "Session resume using tickets #2 (cache disabled)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 277 | "$P_SRV debug_level=4 tickets=1 cache_max=0" \ |
| 278 | "$P_CLI debug_level=4 tickets=1 reconnect=1" \ |
Manuel Pégourié-Gonnard | dbe1ee1 | 2014-02-21 09:18:13 +0100 | [diff] [blame] | 279 | 0 \ |
| 280 | -c "client hello, adding session ticket extension" \ |
| 281 | -s "found session ticket extension" \ |
| 282 | -s "server hello, adding session ticket extension" \ |
| 283 | -c "found session_ticket extension" \ |
| 284 | -c "parse new session ticket" \ |
| 285 | -S "session successfully restored from cache" \ |
| 286 | -s "session successfully restored from ticket" \ |
| 287 | -s "a session has been resumed" \ |
| 288 | -c "a session has been resumed" |
| 289 | |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 290 | run_test "Session resume using tickets #3 (timeout)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 291 | "$P_SRV debug_level=4 tickets=1 cache_max=0 ticket_timeout=1" \ |
| 292 | "$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] | 293 | 0 \ |
| 294 | -c "client hello, adding session ticket extension" \ |
| 295 | -s "found session ticket extension" \ |
| 296 | -s "server hello, adding session ticket extension" \ |
| 297 | -c "found session_ticket extension" \ |
| 298 | -c "parse new session ticket" \ |
| 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 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 304 | run_test "Session resume using tickets #4 (openssl server)" \ |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 305 | "openssl s_server $O_ARGS" \ |
| 306 | "$P_CLI debug_level=4 tickets=1 reconnect=1" \ |
| 307 | 0 \ |
| 308 | -c "client hello, adding session ticket extension" \ |
| 309 | -c "found session_ticket extension" \ |
| 310 | -c "parse new session ticket" \ |
| 311 | -c "a session has been resumed" |
| 312 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 313 | run_test "Session resume using tickets #5 (openssl client)" \ |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 314 | "$P_SRV debug_level=4 tickets=1" \ |
| 315 | "($O_CLI -sess_out sess; $O_CLI -sess_in sess; rm -f sess)" \ |
| 316 | 0 \ |
| 317 | -s "found session ticket extension" \ |
| 318 | -s "server hello, adding session ticket extension" \ |
| 319 | -S "session successfully restored from cache" \ |
| 320 | -s "session successfully restored from ticket" \ |
| 321 | -s "a session has been resumed" |
| 322 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 323 | # Tests for Session Resume based on session-ID and cache |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 324 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 325 | 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] | 326 | "$P_SRV debug_level=4 tickets=0" \ |
| 327 | "$P_CLI debug_level=4 tickets=1 reconnect=1" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 328 | 0 \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 329 | -c "client hello, adding session ticket extension" \ |
| 330 | -s "found session ticket extension" \ |
| 331 | -S "server hello, adding session ticket extension" \ |
| 332 | -C "found session_ticket extension" \ |
| 333 | -C "parse new session ticket" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 334 | -s "session successfully restored from cache" \ |
| 335 | -S "session successfully restored from ticket" \ |
| 336 | -s "a session has been resumed" \ |
| 337 | -c "a session has been resumed" |
| 338 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 339 | 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] | 340 | "$P_SRV debug_level=4 tickets=1" \ |
| 341 | "$P_CLI debug_level=4 tickets=0 reconnect=1" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 342 | 0 \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 343 | -C "client hello, adding session ticket extension" \ |
| 344 | -S "found session ticket extension" \ |
| 345 | -S "server hello, adding session ticket extension" \ |
| 346 | -C "found session_ticket extension" \ |
| 347 | -C "parse new session ticket" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 348 | -s "session successfully restored from cache" \ |
| 349 | -S "session successfully restored from ticket" \ |
| 350 | -s "a session has been resumed" \ |
| 351 | -c "a session has been resumed" |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 352 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 353 | run_test "Session resume using cache #3 (cache_max=0)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 354 | "$P_SRV debug_level=4 tickets=0 cache_max=0" \ |
| 355 | "$P_CLI debug_level=4 tickets=0 reconnect=1" \ |
Manuel Pégourié-Gonnard | 4c88345 | 2014-02-20 21:32:41 +0100 | [diff] [blame] | 356 | 0 \ |
| 357 | -S "session successfully restored from cache" \ |
| 358 | -S "session successfully restored from ticket" \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 359 | -S "a session has been resumed" \ |
| 360 | -C "a session has been resumed" |
Manuel Pégourié-Gonnard | 4c88345 | 2014-02-20 21:32:41 +0100 | [diff] [blame] | 361 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 362 | run_test "Session resume using cache #4 (cache_max=1)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 363 | "$P_SRV debug_level=4 tickets=0 cache_max=1" \ |
| 364 | "$P_CLI debug_level=4 tickets=0 reconnect=1" \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 365 | 0 \ |
| 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 | |
| 371 | run_test "Session resume using cache #5 (timemout > delay)" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 372 | "$P_SRV debug_level=4 tickets=0" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 373 | "$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] | 374 | 0 \ |
| 375 | -s "session successfully restored from cache" \ |
| 376 | -S "session successfully restored from ticket" \ |
| 377 | -s "a session has been resumed" \ |
| 378 | -c "a session has been resumed" |
| 379 | |
| 380 | run_test "Session resume using cache #6 (timeout < delay)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 381 | "$P_SRV debug_level=4 tickets=0 cache_timeout=1" \ |
| 382 | "$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] | 383 | 0 \ |
| 384 | -S "session successfully restored from cache" \ |
| 385 | -S "session successfully restored from ticket" \ |
| 386 | -S "a session has been resumed" \ |
| 387 | -C "a session has been resumed" |
| 388 | |
| 389 | run_test "Session resume using cache #7 (no timeout)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 390 | "$P_SRV debug_level=4 tickets=0 cache_timeout=0" \ |
| 391 | "$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] | 392 | 0 \ |
| 393 | -s "session successfully restored from cache" \ |
| 394 | -S "session successfully restored from ticket" \ |
| 395 | -s "a session has been resumed" \ |
| 396 | -c "a session has been resumed" |
| 397 | |
Manuel Pégourié-Gonnard | db735f6 | 2014-02-25 17:57:59 +0100 | [diff] [blame] | 398 | run_test "Session resume using cache #8 (openssl client)" \ |
| 399 | "$P_SRV debug_level=4 tickets=0" \ |
| 400 | "($O_CLI -sess_out sess; $O_CLI -sess_in sess; rm -f sess)" \ |
| 401 | 0 \ |
| 402 | -s "found session ticket extension" \ |
| 403 | -S "server hello, adding session ticket extension" \ |
| 404 | -s "session successfully restored from cache" \ |
| 405 | -S "session successfully restored from ticket" \ |
| 406 | -s "a session has been resumed" |
| 407 | |
| 408 | run_test "Session resume using cache #9 (openssl server)" \ |
| 409 | "openssl s_server $O_ARGS" \ |
| 410 | "$P_CLI debug_level=4 tickets=0 reconnect=1" \ |
| 411 | 0 \ |
| 412 | -C "found session_ticket extension" \ |
| 413 | -C "parse new session ticket" \ |
| 414 | -c "a session has been resumed" |
| 415 | |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 416 | # Tests for Max Fragment Length extension |
| 417 | |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 418 | run_test "Max fragment length #1" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 419 | "$P_SRV debug_level=4" \ |
| 420 | "$P_CLI debug_level=4" \ |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 421 | 0 \ |
| 422 | -C "client hello, adding max_fragment_length extension" \ |
| 423 | -S "found max fragment length extension" \ |
| 424 | -S "server hello, max_fragment_length extension" \ |
| 425 | -C "found max_fragment_length extension" |
| 426 | |
| 427 | run_test "Max fragment length #2" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 428 | "$P_SRV debug_level=4" \ |
| 429 | "$P_CLI debug_level=4 max_frag_len=4096" \ |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 430 | 0 \ |
| 431 | -c "client hello, adding max_fragment_length extension" \ |
| 432 | -s "found max fragment length extension" \ |
| 433 | -s "server hello, max_fragment_length extension" \ |
| 434 | -c "found max_fragment_length extension" |
| 435 | |
| 436 | run_test "Max fragment length #3" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 437 | "$P_SRV debug_level=4 max_frag_len=4096" \ |
| 438 | "$P_CLI debug_level=4" \ |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 439 | 0 \ |
| 440 | -C "client hello, adding max_fragment_length extension" \ |
| 441 | -S "found max fragment length extension" \ |
| 442 | -S "server hello, max_fragment_length extension" \ |
| 443 | -C "found max_fragment_length extension" |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 444 | |
| 445 | # Tests for renegotiation |
| 446 | |
| 447 | run_test "Renegotiation #0 (none)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 448 | "$P_SRV debug_level=4" \ |
| 449 | "$P_CLI debug_level=4" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 450 | 0 \ |
| 451 | -C "client hello, adding renegotiation extension" \ |
| 452 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 453 | -S "found renegotiation extension" \ |
| 454 | -s "server hello, secure renegotiation extension" \ |
| 455 | -c "found renegotiation extension" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 456 | -C "=> renegotiate" \ |
| 457 | -S "=> renegotiate" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 458 | -S "write hello request" |
| 459 | |
| 460 | run_test "Renegotiation #1 (enabled, client-initiated)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 461 | "$P_SRV debug_level=4" \ |
| 462 | "$P_CLI debug_level=4 renegotiate=1" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 463 | 0 \ |
| 464 | -c "client hello, adding renegotiation extension" \ |
| 465 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 466 | -s "found renegotiation extension" \ |
| 467 | -s "server hello, secure renegotiation extension" \ |
| 468 | -c "found renegotiation extension" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 469 | -c "=> renegotiate" \ |
| 470 | -s "=> renegotiate" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 471 | -S "write hello request" |
| 472 | |
| 473 | run_test "Renegotiation #2 (enabled, server-initiated)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 474 | "$P_SRV debug_level=4 renegotiate=1" \ |
| 475 | "$P_CLI debug_level=4" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 476 | 0 \ |
| 477 | -c "client hello, adding renegotiation extension" \ |
| 478 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 479 | -s "found renegotiation extension" \ |
| 480 | -s "server hello, secure renegotiation extension" \ |
| 481 | -c "found renegotiation extension" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 482 | -c "=> renegotiate" \ |
| 483 | -s "=> renegotiate" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 484 | -s "write hello request" |
| 485 | |
| 486 | run_test "Renegotiation #3 (enabled, double)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 487 | "$P_SRV debug_level=4 renegotiate=1" \ |
| 488 | "$P_CLI debug_level=4 renegotiate=1" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 489 | 0 \ |
| 490 | -c "client hello, adding renegotiation extension" \ |
| 491 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 492 | -s "found renegotiation extension" \ |
| 493 | -s "server hello, secure renegotiation extension" \ |
| 494 | -c "found renegotiation extension" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 495 | -c "=> renegotiate" \ |
| 496 | -s "=> renegotiate" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 497 | -s "write hello request" |
| 498 | |
| 499 | run_test "Renegotiation #4 (client-initiated, server-rejected)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 500 | "$P_SRV debug_level=4 renegotiation=0" \ |
| 501 | "$P_CLI debug_level=4 renegotiate=1" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 502 | 1 \ |
| 503 | -c "client hello, adding renegotiation extension" \ |
| 504 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 505 | -S "found renegotiation extension" \ |
| 506 | -s "server hello, secure renegotiation extension" \ |
| 507 | -c "found renegotiation extension" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 508 | -c "=> renegotiate" \ |
| 509 | -S "=> renegotiate" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 510 | -S "write hello request" |
| 511 | |
| 512 | run_test "Renegotiation #5 (server-initiated, client-rejected)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 513 | "$P_SRV debug_level=4 renegotiate=1" \ |
| 514 | "$P_CLI debug_level=4 renegotiation=0" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 515 | 0 \ |
| 516 | -C "client hello, adding renegotiation extension" \ |
| 517 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 518 | -S "found renegotiation extension" \ |
| 519 | -s "server hello, secure renegotiation extension" \ |
| 520 | -c "found renegotiation extension" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 521 | -C "=> renegotiate" \ |
| 522 | -S "=> renegotiate" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 523 | -s "write hello request" \ |
| 524 | -s "SSL - An unexpected message was received from our peer" \ |
| 525 | -s "failed" |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 526 | |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 527 | # Tests for auth_mode |
| 528 | |
| 529 | run_test "Authentication #1 (server badcert, client required)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 530 | "$P_SRV crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 531 | key_file=data_files/server5.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 532 | "$P_CLI debug_level=2 auth_mode=required" \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 533 | 1 \ |
| 534 | -c "x509_verify_cert() returned" \ |
| 535 | -c "! self-signed or not signed by a trusted CA" \ |
| 536 | -c "! ssl_handshake returned" \ |
| 537 | -c "X509 - Certificate verification failed" |
| 538 | |
| 539 | run_test "Authentication #2 (server badcert, client optional)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 540 | "$P_SRV crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 541 | key_file=data_files/server5.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 542 | "$P_CLI debug_level=2 auth_mode=optional" \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 543 | 0 \ |
| 544 | -c "x509_verify_cert() returned" \ |
| 545 | -c "! self-signed or not signed by a trusted CA" \ |
| 546 | -C "! ssl_handshake returned" \ |
| 547 | -C "X509 - Certificate verification failed" |
| 548 | |
| 549 | run_test "Authentication #3 (server badcert, client none)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 550 | "$P_SRV crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 551 | key_file=data_files/server5.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 552 | "$P_CLI debug_level=2 auth_mode=none" \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 553 | 0 \ |
| 554 | -C "x509_verify_cert() returned" \ |
| 555 | -C "! self-signed or not signed by a trusted CA" \ |
| 556 | -C "! ssl_handshake returned" \ |
| 557 | -C "X509 - Certificate verification failed" |
| 558 | |
| 559 | run_test "Authentication #4 (client badcert, server required)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 560 | "$P_SRV debug_level=4 auth_mode=required" \ |
| 561 | "$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] | 562 | key_file=data_files/server5.key" \ |
| 563 | 1 \ |
| 564 | -S "skip write certificate request" \ |
| 565 | -C "skip parse certificate request" \ |
| 566 | -c "got a certificate request" \ |
| 567 | -C "skip write certificate" \ |
| 568 | -C "skip write certificate verify" \ |
| 569 | -S "skip parse certificate verify" \ |
| 570 | -s "x509_verify_cert() returned" \ |
| 571 | -S "! self-signed or not signed by a trusted CA" \ |
| 572 | -s "! ssl_handshake returned" \ |
| 573 | -c "! ssl_handshake returned" \ |
| 574 | -s "X509 - Certificate verification failed" |
| 575 | |
| 576 | run_test "Authentication #5 (client badcert, server optional)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 577 | "$P_SRV debug_level=4 auth_mode=optional" \ |
| 578 | "$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] | 579 | key_file=data_files/server5.key" \ |
| 580 | 0 \ |
| 581 | -S "skip write certificate request" \ |
| 582 | -C "skip parse certificate request" \ |
| 583 | -c "got a certificate request" \ |
| 584 | -C "skip write certificate" \ |
| 585 | -C "skip write certificate verify" \ |
| 586 | -S "skip parse certificate verify" \ |
| 587 | -s "x509_verify_cert() returned" \ |
| 588 | -s "! self-signed or not signed by a trusted CA" \ |
| 589 | -S "! ssl_handshake returned" \ |
| 590 | -C "! ssl_handshake returned" \ |
| 591 | -S "X509 - Certificate verification failed" |
| 592 | |
| 593 | run_test "Authentication #6 (client badcert, server none)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 594 | "$P_SRV debug_level=4 auth_mode=none" \ |
| 595 | "$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] | 596 | key_file=data_files/server5.key" \ |
| 597 | 0 \ |
| 598 | -s "skip write certificate request" \ |
| 599 | -C "skip parse certificate request" \ |
| 600 | -c "got no certificate request" \ |
| 601 | -c "skip write certificate" \ |
| 602 | -c "skip write certificate verify" \ |
| 603 | -s "skip parse certificate verify" \ |
| 604 | -S "x509_verify_cert() returned" \ |
| 605 | -S "! self-signed or not signed by a trusted CA" \ |
| 606 | -S "! ssl_handshake returned" \ |
| 607 | -C "! ssl_handshake returned" \ |
| 608 | -S "X509 - Certificate verification failed" |
| 609 | |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 610 | # tests for SNI |
| 611 | |
| 612 | run_test "SNI #0 (no SNI callback)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 613 | "$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] | 614 | 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] | 615 | "$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] | 616 | server_name=localhost" \ |
| 617 | 0 \ |
| 618 | -S "parse ServerName extension" \ |
| 619 | -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \ |
| 620 | -c "subject name *: C=NL, O=PolarSSL, CN=localhost" |
| 621 | |
| 622 | run_test "SNI #1 (matching cert 1)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 623 | "$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] | 624 | crt_file=data_files/server5.crt key_file=data_files/server5.key \ |
| 625 | 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] | 626 | "$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] | 627 | server_name=localhost" \ |
| 628 | 0 \ |
| 629 | -s "parse ServerName extension" \ |
| 630 | -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \ |
| 631 | -c "subject name *: C=NL, O=PolarSSL, CN=localhost" |
| 632 | |
| 633 | run_test "SNI #2 (matching cert 2)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 634 | "$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] | 635 | crt_file=data_files/server5.crt key_file=data_files/server5.key \ |
| 636 | 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] | 637 | "$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] | 638 | server_name='PolarSSL Server 1'" \ |
| 639 | 0 \ |
| 640 | -s "parse ServerName extension" \ |
| 641 | -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \ |
| 642 | -c "subject name *: C=NL, O=PolarSSL, CN=PolarSSL Server 1" |
| 643 | |
| 644 | run_test "SNI #3 (no matching cert)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 645 | "$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] | 646 | crt_file=data_files/server5.crt key_file=data_files/server5.key \ |
| 647 | 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] | 648 | "$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] | 649 | server_name='PolarSSL Server 2'" \ |
| 650 | 1 \ |
| 651 | -s "parse ServerName extension" \ |
| 652 | -s "ssl_sni_wrapper() returned" \ |
| 653 | -s "ssl_handshake returned" \ |
| 654 | -c "ssl_handshake returned" \ |
| 655 | -c "SSL - A fatal alert message was received from our peer" |
| 656 | |
Manuel Pégourié-Gonnard | 0b6609b | 2014-02-26 14:45:12 +0100 | [diff] [blame] | 657 | # Tests for non-blocking I/O: exercise a variety of handshake flows |
| 658 | |
| 659 | run_test "Non-blocking I/O #1 (basic handshake)" \ |
| 660 | "$P_SRV nbio=2 tickets=0 auth_mode=none" \ |
| 661 | "$P_CLI nbio=2 tickets=0" \ |
| 662 | 0 \ |
| 663 | -S "ssl_handshake returned" \ |
| 664 | -C "ssl_handshake returned" \ |
| 665 | -c "Read from server: .* bytes read" |
| 666 | |
| 667 | run_test "Non-blocking I/O #2 (client auth)" \ |
| 668 | "$P_SRV nbio=2 tickets=0 auth_mode=required" \ |
| 669 | "$P_CLI nbio=2 tickets=0" \ |
| 670 | 0 \ |
| 671 | -S "ssl_handshake returned" \ |
| 672 | -C "ssl_handshake returned" \ |
| 673 | -c "Read from server: .* bytes read" |
| 674 | |
| 675 | run_test "Non-blocking I/O #3 (ticket)" \ |
| 676 | "$P_SRV nbio=2 tickets=1 auth_mode=none" \ |
| 677 | "$P_CLI nbio=2 tickets=1" \ |
| 678 | 0 \ |
| 679 | -S "ssl_handshake returned" \ |
| 680 | -C "ssl_handshake returned" \ |
| 681 | -c "Read from server: .* bytes read" |
| 682 | |
| 683 | run_test "Non-blocking I/O #4 (ticket + client auth)" \ |
| 684 | "$P_SRV nbio=2 tickets=1 auth_mode=required" \ |
| 685 | "$P_CLI nbio=2 tickets=1" \ |
| 686 | 0 \ |
| 687 | -S "ssl_handshake returned" \ |
| 688 | -C "ssl_handshake returned" \ |
| 689 | -c "Read from server: .* bytes read" |
| 690 | |
| 691 | run_test "Non-blocking I/O #5 (ticket + client auth + resume)" \ |
| 692 | "$P_SRV nbio=2 tickets=1 auth_mode=required" \ |
| 693 | "$P_CLI nbio=2 tickets=1 reconnect=1" \ |
| 694 | 0 \ |
| 695 | -S "ssl_handshake returned" \ |
| 696 | -C "ssl_handshake returned" \ |
| 697 | -c "Read from server: .* bytes read" |
| 698 | |
| 699 | run_test "Non-blocking I/O #6 (ticket + resume)" \ |
| 700 | "$P_SRV nbio=2 tickets=1 auth_mode=none" \ |
| 701 | "$P_CLI nbio=2 tickets=1 reconnect=1" \ |
| 702 | 0 \ |
| 703 | -S "ssl_handshake returned" \ |
| 704 | -C "ssl_handshake returned" \ |
| 705 | -c "Read from server: .* bytes read" |
| 706 | |
| 707 | run_test "Non-blocking I/O #7 (session-id resume)" \ |
| 708 | "$P_SRV nbio=2 tickets=0 auth_mode=none" \ |
| 709 | "$P_CLI nbio=2 tickets=0 reconnect=1" \ |
| 710 | 0 \ |
| 711 | -S "ssl_handshake returned" \ |
| 712 | -C "ssl_handshake returned" \ |
| 713 | -c "Read from server: .* bytes read" |
| 714 | |
Manuel Pégourié-Gonnard | a3d808e | 2014-02-26 16:33:03 +0100 | [diff] [blame] | 715 | run_test "Version check #1 (all -> 1.2)" \ |
| 716 | "$P_SRV" \ |
| 717 | "$P_CLI" \ |
| 718 | 0 \ |
| 719 | -S "ssl_handshake returned" \ |
| 720 | -C "ssl_handshake returned" \ |
| 721 | -s "Protocol is TLSv1.2" \ |
| 722 | -c "Protocol is TLSv1.2" |
| 723 | |
| 724 | run_test "Version check #2 (cli max 1.1 -> 1.1)" \ |
| 725 | "$P_SRV" \ |
| 726 | "$P_CLI max_version=tls1_1" \ |
| 727 | 0 \ |
| 728 | -S "ssl_handshake returned" \ |
| 729 | -C "ssl_handshake returned" \ |
| 730 | -s "Protocol is TLSv1.1" \ |
| 731 | -c "Protocol is TLSv1.1" |
| 732 | |
| 733 | run_test "Version check #3 (srv max 1.1 -> 1.1)" \ |
| 734 | "$P_SRV max_version=tls1_1" \ |
| 735 | "$P_CLI" \ |
| 736 | 0 \ |
| 737 | -S "ssl_handshake returned" \ |
| 738 | -C "ssl_handshake returned" \ |
| 739 | -s "Protocol is TLSv1.1" \ |
| 740 | -c "Protocol is TLSv1.1" |
| 741 | |
| 742 | run_test "Version check #4 (cli+srv max 1.1 -> 1.1)" \ |
| 743 | "$P_SRV max_version=tls1_1" \ |
| 744 | "$P_CLI max_version=tls1_1" \ |
| 745 | 0 \ |
| 746 | -S "ssl_handshake returned" \ |
| 747 | -C "ssl_handshake returned" \ |
| 748 | -s "Protocol is TLSv1.1" \ |
| 749 | -c "Protocol is TLSv1.1" |
| 750 | |
| 751 | run_test "Version check #5 (cli max 1.1, srv min 1.1 -> 1.1)" \ |
| 752 | "$P_SRV min_version=tls1_1" \ |
| 753 | "$P_CLI max_version=tls1_1" \ |
| 754 | 0 \ |
| 755 | -S "ssl_handshake returned" \ |
| 756 | -C "ssl_handshake returned" \ |
| 757 | -s "Protocol is TLSv1.1" \ |
| 758 | -c "Protocol is TLSv1.1" |
| 759 | |
| 760 | run_test "Version check #6 (cli min 1.1, srv max 1.1 -> 1.1)" \ |
| 761 | "$P_SRV max_version=tls1_1" \ |
| 762 | "$P_CLI min_version=tls1_1" \ |
| 763 | 0 \ |
| 764 | -S "ssl_handshake returned" \ |
| 765 | -C "ssl_handshake returned" \ |
| 766 | -s "Protocol is TLSv1.1" \ |
| 767 | -c "Protocol is TLSv1.1" |
| 768 | |
| 769 | run_test "Version check #7 (cli min 1.2, srv max 1.1 -> fail)" \ |
| 770 | "$P_SRV max_version=tls1_1" \ |
| 771 | "$P_CLI min_version=tls1_2" \ |
| 772 | 1 \ |
| 773 | -s "ssl_handshake returned" \ |
| 774 | -c "ssl_handshake returned" \ |
| 775 | -c "SSL - Handshake protocol not within min/max boundaries" |
| 776 | |
| 777 | run_test "Version check #8 (srv min 1.2, cli max 1.1 -> fail)" \ |
| 778 | "$P_SRV min_version=tls1_2" \ |
| 779 | "$P_CLI max_version=tls1_1" \ |
| 780 | 1 \ |
| 781 | -s "ssl_handshake returned" \ |
| 782 | -c "ssl_handshake returned" \ |
| 783 | -s "SSL - Handshake protocol not within min/max boundaries" |
| 784 | |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 785 | # Final report |
| 786 | |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 787 | echo "------------------------------------------------------------------------" |
| 788 | |
| 789 | if [ $FAILS = 0 ]; then |
| 790 | echo -n "PASSED" |
| 791 | else |
| 792 | echo -n "FAILED" |
| 793 | fi |
| 794 | PASSES=`echo $TESTS - $FAILS | bc` |
Manuel Pégourié-Gonnard | 4145b89 | 2014-02-24 13:20:14 +0100 | [diff] [blame] | 795 | echo " ($PASSES / $TESTS tests)" |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 796 | |
| 797 | exit $FAILS |