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