Skip to content

Commit

Permalink
tests: Run different TLS versions and tests with different keys and a…
Browse files Browse the repository at this point in the history
…lgorithms

Signed-off-by: Jakub Jelen <[email protected]>
  • Loading branch information
Jakuje committed Jul 17, 2024
1 parent adce91a commit 78f4ce6
Showing 1 changed file with 58 additions and 33 deletions.
91 changes: 58 additions & 33 deletions tests/ttls
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,63 @@ trap 'wait_for_server_at_exit $SERVER_PID;' EXIT

PORT=23456

expect -c "spawn $CHECKER openssl s_server -accept \"${PORT}\" -naccept 1 -key \"${PRIURI}\" -cert \"${CRTURI}\";
set timeout 60;
expect {
\"ACCEPT\" {};
default {exit 1;};
}
set server_ready [open \"${TMPPDIR}/s_server_ready\" w+];
puts \$server_ready \"READY\n\";
close \$server_ready;
expect {
\"END SSL SESSION PARAMETERS\" {};
default {exit 1;};
}
send \" TLS SUCCESSFUL \n\"
send \"Q\n\"
expect {
eof {exit 0;};
default {exit 1;};
}" > "${TMPPDIR}/s_server_output" &
SERVER_PID=$!

read -r < "${TMPPDIR}/s_server_ready"

expect -c "spawn $CHECKER openssl s_client -connect \"localhost:${PORT}\";
set timeout 60;
expect {
\" TLS SUCCESSFUL \" {};
default {exit 1;};
}
expect {
eof {exit 0;};
default {exit 1;};
}"
run_test() {
KEY="$1"
CERT="$2"
SRV_ARGS=$3
CLNT_ARGS=$4
expect -c "spawn $CHECKER openssl s_server -accept \"${PORT}\" -naccept 1 -key \"${KEY}\" -cert \"${CERT}\" $SRV_ARGS;
set timeout 60;
expect {
\"ACCEPT\" {};
default {exit 1;};
}
set server_ready [open \"${TMPPDIR}/s_server_ready\" w+];
puts \$server_ready \"READY\n\";
close \$server_ready;
expect {
\"END SSL SESSION PARAMETERS\" {};
default {exit 1;};
}
send \" TLS SUCCESSFUL \n\"
send \"Q\n\"
expect {
eof {exit 0;};
default {exit 1;};
}" > "${TMPPDIR}/s_server_output" &
SERVER_PID=$!

read -r < "${TMPPDIR}/s_server_ready"

expect -c "spawn $CHECKER openssl s_client -connect \"localhost:${PORT}\" $CLNT_ARGS;
set timeout 60;
expect {
\" TLS SUCCESSFUL \" {};
default {exit 1;};
}
expect {
eof {exit 0;};
default {exit 1;};
}"

}

title PARA "Run sanity test with default values (RSA)"
run_test "$PRIURI" "$CRTURI"

title PARA "Run sanity test with default values (ECDSA)"
run_test "$ECPRIURI" "$ECCRTURI"

title PARA "Run test with TLS 1.2"
run_test "$PRIURI" "$CRTURI" "" "-tls1_2"

title PARA "Run test with explicit TLS 1.3"
run_test "$PRIURI" "$CRTURI" "" "-tls1_3"

title PARA "Run test with TLS 1.2 (ECDSA)"
run_test "$ECPRIURI" "$ECCRTURI" "" "-tls1_2"

title PARA "Run test with TLS 1.2 and ECDH"
run_test "$ECPRIURI" "$ECCRTURI" "" "-tls1_2 -cipher ECDHE-ECDSA-AES128-GCM-SHA256 -groups secp256r1"

exit 0;

0 comments on commit 78f4ce6

Please sign in to comment.