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