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