mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-08-18 17:43:24 +02:00
SendTls13Certificate keeps its chain walk cursor in the function locals len, idx, offset and p, but the only state that survives the WANT_WRITE return of a non-blocking send is ssl->fragOffset, and that is consulted for the leaf certificate alone. A send that blocked part way through the chain therefore re-primed the walk on the next call and copied the chain from its first byte again. The byte count still matched the announced payload size, so the message stayed well formed on the wire while the tail of the chain was replaced by a repeat of its head, and the peer rejected it with BUFFER_ERROR. Rebuild the cursor from ssl->fragOffset when a resume lands inside the chain. NextCert reads each entry's three byte length prefix and skips it, so passing over the entries already sent costs one hop per certificate and only happens on a resume. Guard the extension index bump the same way the send loop does, so builds without certificate status request keep the leaf extension size. Track the size of the chain entry being written in its own variable rather than folding the extension size into len once the entry completes. The send loop detected completion with offset == len + OPAQUE16_LEN and kept that check honest by adding extSz[extIdx] - OPAQUE16_LEN to len at the end of an entry, so until then len held the raw certificate length and the check read as complete whenever a fragment boundary landed exactly OPAQUE16_LEN bytes into a real extension. The walk then jumped to the next certificate in the middle of the current one. entrySz records len + extSz[extIdx] when the entry is picked up, len keeps the raw certificate length AddCertExt expects, and both the resume and the ordinary multi fragment path test the same condition. The stapled chain in scripts/ocsp-stapling_tls13multi.test reproduces the entry size case with the server records held to 1482 bytes: the boundary falls two bytes into an 1837 byte OCSP extension and the handshake fails, while 1480, 1481, 1483 and 1484 all pass. Reaching this needs a certificate message larger than one record, which is why it stayed dormant with classic certificates. Add SLH-DSA scenarios with simulated WANT_WRITE, for server and for mutual authentication, to tests/test-tls13-slhdsa-entity-128s.conf. The same resume path mishandles the stapled OCSP responses. WriteCSRToBuffer fills extSz[] only for the entries whose buffer it allocates, so on a resumed call every entry that still held a buffer, the one being written and all that follow it, kept the OPAQUE16_LEN default of an empty extension. The message length, the entry sizes and the extension bytes written for those entries were all derived from that default. Recover the size from the extension length already written into the buffer instead. SetupOcspResp appends a fresh request per certificate on every call, so a message that resumed often enough exhausted the extension array and the handshake ended with MAX_CERT_EXTENSIONS_ERR. Look the responses up once, when the message starts, and reuse them for the rest of it. A resumed call also reallocates the extension buffers of the entries it has already sent, and the walk passes over those entries without writing them again, so free them there. Free the array in wolfSSL_ResourceFree as well: nothing released it when a connection ended part way through a Certificate message, which leaked one OCSP response per unsent entry. Test case 8 of scripts/ocsp-stapling_tls13multi.test covers all three. A maximum fragment length of 512 bytes splits the stapled message over about twenty records and the server blocks on every one of them; without these fixes the handshake fails with MAX_CERT_EXTENSIONS_ERR.
563 lines
20 KiB
Bash
Executable File
563 lines
20 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# timeout(1) is GNU coreutils and absent on macOS; where it's missing, run the
|
|
# command unbounded (the flaky hang this guards against is Linux-only CI).
|
|
if ! command -v timeout >/dev/null 2>&1; then
|
|
timeout() { while [ "${1:-}" = "-s" ] || [ "${1:-}" = "-k" ]; do shift 2; done; shift; "$@"; }
|
|
fi
|
|
|
|
|
|
# ocsp-stapling_tls13multi.test
|
|
# Test requires HAVE_OCSP and HAVE_CERTIFICATE_STATUS_REQUEST_V2
|
|
|
|
SCRIPT_DIR="$(dirname "$0")"
|
|
|
|
# if we can, isolate the network namespace to eliminate port collisions.
|
|
if [[ -n "$NETWORK_UNSHARE_HELPER" ]]; then
|
|
if [[ -z "$NETWORK_UNSHARE_HELPER_CALLED" ]]; then
|
|
export NETWORK_UNSHARE_HELPER_CALLED=yes
|
|
exec "$NETWORK_UNSHARE_HELPER" "$0" "$@" || exit $?
|
|
fi
|
|
elif [ "${AM_BWRAPPED-}" != "yes" ]; then
|
|
bwrap_path="$(command -v bwrap)"
|
|
if [ -n "$bwrap_path" ]; then
|
|
export AM_BWRAPPED=yes
|
|
exec "$bwrap_path" --unshare-net --dev-bind / / "$0" "$@"
|
|
fi
|
|
unset AM_BWRAPPED
|
|
fi
|
|
|
|
if [[ -z "${RETRIES_REMAINING-}" ]]; then
|
|
export RETRIES_REMAINING=2
|
|
fi
|
|
|
|
[ ! -x ./examples/client/client ] && printf '\n\n%s\n' "Client doesn't exist" \
|
|
&& exit 1
|
|
|
|
[ ! -x ./examples/server/server ] && printf '\n\n%s\n' "Server doesn't exist" \
|
|
&& exit 1
|
|
|
|
if ./examples/client/client -? 2>&1 | grep "Client not compiled in!" ; then
|
|
echo 'skipping ocsp-stapling_tls13multi.test because client not compiled in.' 1>&2
|
|
exit 77
|
|
fi
|
|
|
|
if ./examples/server/server -? 2>&1 | grep "Server not compiled in!" ; then
|
|
echo 'skipping ocsp-stapling_tls13multi.test because server not compiled in.' 1>&2
|
|
exit 77
|
|
fi
|
|
|
|
if ! ./examples/client/client -V | grep -q 4; then
|
|
tls13=no
|
|
|
|
else
|
|
tls13=yes
|
|
fi
|
|
|
|
if ! ./examples/client/client -? 2>&1 | grep -q 'DTLSv1.3'; then
|
|
dtls13=no
|
|
else
|
|
dtls13=yes
|
|
fi
|
|
|
|
# The fragmented-send case needs a client that can request a small maximum
|
|
# fragment length and a server that can simulate WANT_WRITE. Both options are
|
|
# silently ignored otherwise, which would turn the case into a no-op that still
|
|
# reports PASSED.
|
|
if ! ./examples/client/client -? 2>&1 | grep -q 'Maximum Fragment Length'; then
|
|
fragmented_send=no
|
|
elif ./examples/server/server -6 -? 2>&1 | grep -q 'Ignoring -6'; then
|
|
fragmented_send=no
|
|
else
|
|
fragmented_send=yes
|
|
fi
|
|
|
|
if [[ ("$tls13" == "no") && ("$dtls13" == "no") ]]; then
|
|
echo 'skipping ocsp-stapling_tls13multi.test because TLS1.3 is not available.' 1>&2
|
|
exit 77
|
|
fi
|
|
|
|
if ! ./examples/client/client -V | grep -q 4; then
|
|
tls13=no
|
|
echo 'skipping ocsp-stapling_tls13multi.test because TLS1.3 is not available.' 1>&2
|
|
exit 77
|
|
else
|
|
tls13=yes
|
|
fi
|
|
|
|
if openssl s_server -help 2>&1 | grep -F -q -i ipv6 && nc -h 2>&1 | grep -F -q -i ipv6; then
|
|
IPV6_SUPPORTED=yes
|
|
else
|
|
IPV6_SUPPORTED=no
|
|
fi
|
|
|
|
if ./examples/client/client '-#' | grep -F -q -e ' -DTEST_IPV6 '; then
|
|
if [[ "$IPV6_SUPPORTED" == "no" ]]; then
|
|
echo 'Skipping IPV6 test in environment lacking IPV6 support.'
|
|
exit 77
|
|
fi
|
|
LOCALHOST='[::1]'
|
|
LOCALHOST_FOR_NC='-6 ::1'
|
|
else
|
|
LOCALHOST='127.0.0.1'
|
|
LOCALHOST_FOR_NC='127.0.0.1'
|
|
fi
|
|
|
|
PARENTDIR="$PWD"
|
|
|
|
# create a unique workspace directory ending in PID for the script instance ($$)
|
|
# to make this instance orthogonal to any others running, even on same repo.
|
|
# TCP ports are also carefully formed below from the PID, to minimize conflicts.
|
|
|
|
#WORKSPACE="${PARENTDIR}/workspace.pid$$"
|
|
#mkdir "${WORKSPACE}" || exit $?
|
|
|
|
# Use portable mktemp syntax that works on both Linux and macOS
|
|
WORKSPACE="$(mktemp -d "${PARENTDIR}"/wolfssl-ocsp-test.XXXXXX)"
|
|
|
|
cp -pR "${SCRIPT_DIR}"/../certs "${WORKSPACE}"/ || exit $?
|
|
cd "$WORKSPACE" || exit $?
|
|
ln -s ../examples .
|
|
|
|
CERT_DIR="certs/ocsp"
|
|
|
|
|
|
ready_file1="$WORKSPACE"/wolf_ocsp_tls13_readyF1$$
|
|
ready_file2="$WORKSPACE"/wolf_ocsp_tls13_readyF2$$
|
|
ready_file3="$WORKSPACE"/wolf_ocsp_tls13_readyF3$$
|
|
ready_file4="$WORKSPACE"/wolf_ocsp_tls13_readyF4$$
|
|
ready_file5="$WORKSPACE"/wolf_ocsp_tls13_readyF5$$
|
|
printf '%s\n' "ready file 1: $ready_file1"
|
|
printf '%s\n' "ready file 2: $ready_file2"
|
|
printf '%s\n' "ready file 3: $ready_file3"
|
|
printf '%s\n' "ready file 4: $ready_file4"
|
|
printf '%s\n' "ready file 5: $ready_file5"
|
|
|
|
test_cnf="ocsp_s2.cnf"
|
|
|
|
wait_for_readyFile(){
|
|
|
|
counter=0
|
|
|
|
while [ ! -s "$1" ] && [ "$counter" -lt 20 ]; do
|
|
if [[ -n "${2-}" ]]; then
|
|
if ! kill -0 "$2" 2>&-; then
|
|
echo "pid $2 for port ${3-} exited before creating ready file. bailing..."
|
|
exit 1
|
|
fi
|
|
fi
|
|
echo -e "waiting for ready file..."
|
|
sleep 0.1
|
|
counter=$((counter+ 1))
|
|
done
|
|
|
|
if test -e "$1"; then
|
|
echo -e "found ready file, starting client..."
|
|
else
|
|
echo -e "NO ready file at $1 -- ending test..."
|
|
exit 1
|
|
fi
|
|
|
|
}
|
|
|
|
remove_single_rF(){
|
|
if test -e "$1"; then
|
|
printf '%s\n' "removing ready file: $1"
|
|
rm "$1"
|
|
fi
|
|
}
|
|
#create a configure file for cert generation with the port 0 solution
|
|
create_new_cnf() {
|
|
echo "Random Ports Selected: $1 $2 $3 $4"
|
|
|
|
cat <<- EOF > "$test_cnf"
|
|
#
|
|
# openssl configuration file for OCSP certificates
|
|
#
|
|
|
|
# Extensions to add to a certificate request (intermediate1-ca)
|
|
[ v3_req1 ]
|
|
basicConstraints = CA:false
|
|
subjectKeyIdentifier = hash
|
|
authorityKeyIdentifier = keyid:always,issuer:always
|
|
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
|
|
authorityInfoAccess = OCSP;URI:http://127.0.0.1:$1
|
|
|
|
# Extensions to add to a certificate request (intermediate2-ca)
|
|
[ v3_req2 ]
|
|
basicConstraints = CA:false
|
|
subjectKeyIdentifier = hash
|
|
authorityKeyIdentifier = keyid:always,issuer:always
|
|
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
|
|
authorityInfoAccess = OCSP;URI:http://127.0.0.1:$2
|
|
|
|
# Extensions to add to a certificate request (intermediate3-ca)
|
|
[ v3_req3 ]
|
|
basicConstraints = CA:false
|
|
subjectKeyIdentifier = hash
|
|
authorityKeyIdentifier = keyid:always,issuer:always
|
|
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
|
|
authorityInfoAccess = OCSP;URI:http://127.0.0.1:$3
|
|
|
|
# Extensions for a typical CA
|
|
[ v3_ca ]
|
|
basicConstraints = CA:true
|
|
subjectKeyIdentifier = hash
|
|
authorityKeyIdentifier = keyid:always,issuer:always
|
|
keyUsage = keyCertSign, cRLSign
|
|
authorityInfoAccess = OCSP;URI:http://127.0.0.1:$4
|
|
|
|
# OCSP extensions.
|
|
[ v3_ocsp ]
|
|
basicConstraints = CA:false
|
|
subjectKeyIdentifier = hash
|
|
authorityKeyIdentifier = keyid:always,issuer:always
|
|
extendedKeyUsage = OCSPSigning
|
|
EOF
|
|
|
|
mv "$test_cnf" "$CERT_DIR/$test_cnf"
|
|
cd "$CERT_DIR" || exit
|
|
CURR_LOC="$PWD"
|
|
printf '%s\n' "echo now in $CURR_LOC"
|
|
./renewcerts-for-test.sh "$test_cnf"
|
|
cd "$WORKSPACE" || exit
|
|
}
|
|
|
|
remove_ready_file(){
|
|
if test -e "$ready_file1"; then
|
|
printf '%s\n' "removing ready file: $ready_file1"
|
|
rm "$ready_file1"
|
|
fi
|
|
if test -e "$ready_file2"; then
|
|
printf '%s\n' "removing ready file: $ready_file2"
|
|
rm "$ready_file2"
|
|
fi
|
|
if test -e "$ready_file3"; then
|
|
printf '%s\n' "removing ready file: $ready_file3"
|
|
rm "$ready_file3"
|
|
fi
|
|
if test -e "$ready_file4"; then
|
|
printf '%s\n' "removing ready file: $ready_file4"
|
|
rm "$ready_file4"
|
|
fi
|
|
if test -e "$ready_file5"; then
|
|
printf '%s\n' "removing ready file: $ready_file5"
|
|
rm "$ready_file5"
|
|
fi
|
|
}
|
|
|
|
cleanup()
|
|
{
|
|
exit_status=$?
|
|
for i in $(jobs -pr)
|
|
do
|
|
kill -s KILL "$i"
|
|
done
|
|
remove_ready_file
|
|
rm "$CERT_DIR/$test_cnf"
|
|
cd "$PARENTDIR" || return 1
|
|
rm -r "$WORKSPACE" || return 1
|
|
|
|
if [[ ("$exit_status" == 1) && ($RETRIES_REMAINING -gt 0) ]]; then
|
|
echo "retrying..."
|
|
RETRIES_REMAINING=$((RETRIES_REMAINING - 1))
|
|
exec "$0" "$@"
|
|
fi
|
|
}
|
|
trap cleanup EXIT INT TERM HUP
|
|
|
|
[ ! -x ./examples/client/client ] && echo -e "\n\nClient doesn't exist" && exit 1
|
|
|
|
# check if supported key size is large enough to handle 4096 bit RSA
|
|
size="$(./examples/client/client '-?' | grep "Max RSA key")"
|
|
size="${size//[^0-9]/}"
|
|
if [ -n "$size" ]; then
|
|
printf 'check on max key size of %d ...' "$size"
|
|
if [ "$size" -lt 4096 ]; then
|
|
printf '%s\n' "4096 bit RSA keys not supported"
|
|
exit 0
|
|
fi
|
|
printf 'OK\n'
|
|
fi
|
|
|
|
#get four unique ports
|
|
|
|
# choose consecutive ports based on the PID, skipping any that are
|
|
# already bound, to avoid the birthday problem in case other
|
|
# instances are sharing this host.
|
|
|
|
get_first_free_port() {
|
|
local ret="$1"
|
|
while :; do
|
|
if [[ "$ret" -ge 65536 ]]; then
|
|
ret=1024
|
|
fi
|
|
if ! nc -z ${LOCALHOST_FOR_NC} "$ret"; then
|
|
break
|
|
fi
|
|
ret=$((ret+1))
|
|
done
|
|
echo "$ret"
|
|
return 0
|
|
}
|
|
|
|
base_port=$((((($$ + RETRIES_REMAINING) * 5) % (65536 - 2048)) + 1024))
|
|
port1=$(get_first_free_port "$base_port")
|
|
port2=$(get_first_free_port $((port1 + 1)))
|
|
port3=$(get_first_free_port $((port2 + 1)))
|
|
port4=$(get_first_free_port $((port3 + 1)))
|
|
port5=$(get_first_free_port $((port4 + 1)))
|
|
|
|
# 1:
|
|
./examples/server/server -R "$ready_file1" -p "$port1" &
|
|
server_pid1=$!
|
|
wait_for_readyFile "$ready_file1" "$server_pid1" "$port1"
|
|
if [ ! -f "$ready_file1" ]; then
|
|
printf '%s\n' "Failed to create ready file1: \"$ready_file1\""
|
|
exit 1
|
|
fi
|
|
# 2:
|
|
./examples/server/server -R "$ready_file2" -p "$port2" &
|
|
server_pid2=$!
|
|
wait_for_readyFile "$ready_file2" "$server_pid2" "$port2"
|
|
if [ ! -f "$ready_file2" ]; then
|
|
printf '%s\n' "Failed to create ready file2: \"$ready_file2\""
|
|
exit 1
|
|
fi
|
|
# 3:
|
|
./examples/server/server -R "$ready_file3" -p "$port3" &
|
|
server_pid3=$!
|
|
wait_for_readyFile "$ready_file3" "$server_pid3" "$port3"
|
|
if [ ! -f "$ready_file3" ]; then
|
|
printf '%s\n' "Failed to create ready file3: \"$ready_file3\""
|
|
exit 1
|
|
fi
|
|
# 4:
|
|
./examples/server/server -R "$ready_file4" -p "$port4" &
|
|
server_pid4=$!
|
|
wait_for_readyFile "$ready_file4" "$server_pid4" "$port4"
|
|
if [ ! -f "$ready_file4" ]; then
|
|
printf '%s\n' "Failed to create ready file4: \"$ready_file4\""
|
|
exit 1
|
|
fi
|
|
|
|
printf '%s\n' "------------- PORTS ---------------"
|
|
printf '%s' "Random ports selected: $port1 $port2"
|
|
printf '%s\n' " $port3 $port4 $port5"
|
|
printf '%s\n' "-----------------------------------"
|
|
# Use client connections to cleanly shutdown the servers
|
|
./examples/client/client -p "$port1"
|
|
./examples/client/client -p "$port2"
|
|
./examples/client/client -p "$port3"
|
|
./examples/client/client -p "$port4"
|
|
create_new_cnf "$port1" "$port2" "$port3" \
|
|
"$port4"
|
|
|
|
sleep 0.1
|
|
|
|
# setup ocsp responders
|
|
# OLD: ./certs/ocsp/ocspd-root-ca-and-intermediate-cas.sh &
|
|
# NEW: openssl isn't being cleaned up, invoke directly in script for cleanup
|
|
# purposes!
|
|
openssl ocsp -port "$port1" -nmin 1 \
|
|
-index certs/ocsp/index-ca-and-intermediate-cas.txt \
|
|
-rsigner certs/ocsp/ocsp-responder-cert.pem \
|
|
-rkey certs/ocsp/ocsp-responder-key.pem \
|
|
-CA certs/ocsp/root-ca-cert.pem \
|
|
"$@" \
|
|
&
|
|
|
|
# OLD: ./certs/ocsp/ocspd-intermediate2-ca-issued-certs.sh &
|
|
# NEW: openssl isn't being cleaned up, invoke directly in script for cleanup
|
|
# purposes!
|
|
openssl ocsp -port "$port2" -nmin 1 \
|
|
-index certs/ocsp/index-intermediate2-ca-issued-certs.txt \
|
|
-rsigner certs/ocsp/intermediate2-ca-cert.pem \
|
|
-rkey certs/ocsp/intermediate2-ca-key.pem \
|
|
-CA certs/ocsp/intermediate2-ca-cert.pem \
|
|
"$@" \
|
|
&
|
|
|
|
# OLD: ./certs/ocsp/ocspd-intermediate3-ca-issued-certs.sh &
|
|
# NEW: openssl isn't being cleaned up, invoke directly in script for cleanup
|
|
# purposes!
|
|
openssl ocsp -port "$port3" -nmin 1 \
|
|
-index certs/ocsp/index-intermediate3-ca-issued-certs.txt \
|
|
-rsigner certs/ocsp/intermediate3-ca-cert.pem \
|
|
-rkey certs/ocsp/intermediate3-ca-key.pem \
|
|
-CA certs/ocsp/intermediate3-ca-cert.pem \
|
|
"$@" \
|
|
&
|
|
|
|
# NEW: openssl isn't being cleaned up, invoke directly in script for cleanup
|
|
# purposes!
|
|
openssl ocsp -port "$port4" -nmin 1 \
|
|
-index certs/ocsp/index-ca-and-intermediate-cas.txt \
|
|
-rsigner certs/ocsp/ocsp-responder-cert.pem \
|
|
-rkey certs/ocsp/ocsp-responder-key.pem \
|
|
-CA certs/ocsp/root-ca-cert.pem \
|
|
"$@" \
|
|
&
|
|
|
|
sleep 0.1
|
|
# "jobs" is not portable for posix. Must use bash interpreter!
|
|
[ "$(jobs -r | wc -l)" -ne 4 ] && printf '\n\n%s\n' "Setup ocsp responder failed, skipping" && exit 0
|
|
|
|
printf '\n\n%s\n\n' "All OCSP responders started successfully!"
|
|
|
|
if [ "$tls13" == "yes" ]; then
|
|
printf '%s\n\n' "------------- TEST CASE 1 SHOULD PASS ------------------------"
|
|
# client test against our own server - GOOD CERTS
|
|
./examples/server/server -c certs/ocsp/server3-cert.pem \
|
|
-k certs/ocsp/server3-key.pem -R "$ready_file5" \
|
|
-p "$port5" -v 4 &
|
|
server_pid5=$!
|
|
wait_for_readyFile "$ready_file5" "$server_pid5" "$port5"
|
|
./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1 -v 4 \
|
|
-p "$port5"
|
|
RESULT=$?
|
|
[ "$RESULT" -ne 0 ] && printf '\n\n%s\n' "Client connection 1 failed" && exit 1
|
|
printf '%s\n\n' "Test PASSED!"
|
|
|
|
printf '%s\n\n' "------------- TEST CASE 2 SHOULD REVOKE ----------------------"
|
|
# client test against our own server - REVOKED SERVER CERT
|
|
remove_single_rF "$ready_file5"
|
|
./examples/server/server -c certs/ocsp/server4-cert.pem \
|
|
-k certs/ocsp/server4-key.pem -R "$ready_file5" \
|
|
-p "$port5" -v 4 &
|
|
server_pid5=$!
|
|
wait_for_readyFile "$ready_file5" "$server_pid5" "$port5"
|
|
./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1 -v 4 \
|
|
-p "$port5"
|
|
RESULT=$?
|
|
[ "$RESULT" -ne 1 ] && printf '\n\n%s\n' "Client connection succeeded $RESULT" && exit 1
|
|
printf '%s\n\n' "Test successfully REVOKED!"
|
|
|
|
printf '%s\n\n' "------------- TEST CASE 3 SHOULD REVOKE ----------------------"
|
|
remove_single_rF "$ready_file5"
|
|
./examples/server/server -c certs/ocsp/server4-cert.pem \
|
|
-k certs/ocsp/server4-key.pem -R "$ready_file5" \
|
|
-p "$port5" &
|
|
sleep 0.1
|
|
./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1 -v 4 \
|
|
-p "$port5"
|
|
RESULT=$?
|
|
[ "$RESULT" -ne 1 ] && printf '\n\n%s\n' "Client connection succeeded $RESULT" && exit 1
|
|
printf '%s\n\n' "Test successfully REVOKED!"
|
|
|
|
printf '%s\n\n' "------------- TEST CASE 4 SHOULD REVOKE ------------------------"
|
|
# client test against our own server - REVOKED INTERMEDIATE CERT
|
|
remove_single_rF "$ready_file5"
|
|
./examples/server/server -c certs/ocsp/server5-cert.pem \
|
|
-k certs/ocsp/server5-key.pem -R "$ready_file5" \
|
|
-p "$port5" -v 4 &
|
|
server_pid5=$!
|
|
wait_for_readyFile "$ready_file5" "$server_pid5" "$port5"
|
|
./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1 -v 4 \
|
|
-p "$port5"
|
|
RESULT=$?
|
|
[ "$RESULT" -ne 1 ] && printf '\n\n%s\n' "Client connection succeeded $RESULT" && exit 1
|
|
printf '%s\n\n' "Test successfully REVOKED!"
|
|
|
|
printf '%s\n\n' "------------- TEST CASE 5 SHOULD REVOKE ----------------------"
|
|
remove_single_rF "$ready_file5"
|
|
./examples/server/server -c certs/ocsp/server5-cert.pem \
|
|
-k certs/ocsp/server5-key.pem -R "$ready_file5" \
|
|
-p "$port5" -v 4 &
|
|
server_pid5=$!
|
|
wait_for_readyFile "$ready_file5" "$server_pid5" "$port5"
|
|
./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1 -v 4 \
|
|
-p "$port5"
|
|
RESULT=$?
|
|
[ "$RESULT" -ne 1 ] && printf '\n\n%s\n' "Client connection succeeded $RESULT" && exit 1
|
|
printf '%s\n\n' "Test successfully REVOKED!"
|
|
|
|
printf '%s\n\n' "------------- TEST CASE 6 LOAD CERT IN SSL -------------------"
|
|
remove_single_rF "$ready_file5"
|
|
timeout -s KILL 2m ./examples/server/server -c certs/ocsp/server1-cert.pem \
|
|
-k certs/ocsp/server1-key.pem -R "$ready_file5" -v 4 \
|
|
-p "$port5" -H loadSSL &
|
|
server_pid5=$!
|
|
wait_for_readyFile "$ready_file5" "$server_pid5" "$port5"
|
|
echo "test connection" | openssl s_client -status -legacy_renegotiation -connect "${LOCALHOST}:$port5" -cert ./certs/client-cert.pem -key ./certs/client-key.pem -CAfile ./certs/ocsp/root-ca-cert.pem
|
|
RESULT=$?
|
|
[ "$RESULT" -ne 0 ] && printf '\n\n%s\n' "Client connection failed $RESULT" && exit 1
|
|
if ! wait "$server_pid5"; then
|
|
printf '%s\n' "Unexpected server result"
|
|
exit 1
|
|
fi
|
|
printf '%s\n\n' "Test successful"
|
|
printf '%s\n\n' "------------- TEST CASE 7 SHOULD REVOKE ----------------------"
|
|
remove_single_rF "$ready_file5"
|
|
timeout -s KILL 2m ./examples/server/server -c certs/ocsp/server4-cert.pem \
|
|
-k certs/ocsp/server4-key.pem -R "$ready_file5" \
|
|
-p "$port5" -H loadSSL -v 4 &
|
|
server_pid5=$!
|
|
sleep 0.1
|
|
./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1 -v 4 \
|
|
-p "$port5"
|
|
RESULT=$?
|
|
[ "$RESULT" -ne 1 ] && printf '\n\n%s\n' "Client connection succeeded $RESULT" && exit 1
|
|
wait "$server_pid5"
|
|
if [ $? -ne 1 ]; then
|
|
printf '%s\n' "Unexpected server result"
|
|
exit 1
|
|
fi
|
|
printf '%s\n\n' "Test successfully REVOKED!"
|
|
|
|
printf '%s\n\n' "------------- TEST CASE 8 FRAGMENTED SEND --------------------"
|
|
if [ "$fragmented_send" == "no" ]; then
|
|
printf '%s\n\n' "Test SKIPPED: needs HAVE_MAX_FRAGMENT and async I/O."
|
|
else
|
|
# A small maximum fragment length (-F 1) splits the stapled Certificate
|
|
# message over many records, and the server (-6) blocks on every one of
|
|
# them, so the send resumes from a WANT_WRITE inside the chain.
|
|
remove_single_rF "$ready_file5"
|
|
./examples/server/server -c certs/ocsp/server3-cert.pem \
|
|
-k certs/ocsp/server3-key.pem -R "$ready_file5" \
|
|
-p "$port5" -v 4 -6 &
|
|
server_pid5=$!
|
|
wait_for_readyFile "$ready_file5" "$server_pid5" "$port5"
|
|
./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1 -v 4 \
|
|
-F 1 -p "$port5"
|
|
RESULT=$?
|
|
[ "$RESULT" -ne 0 ] && printf '\n\n%s\n' "Client connection 8 failed" \
|
|
&& exit 1
|
|
printf '%s\n\n' "Test PASSED!"
|
|
fi
|
|
fi
|
|
|
|
if [ "$dtls13" == "yes" ]; then
|
|
printf '%s\n\n' "------------- TEST CASE DTLS-1 SHOULD PASS ---------------"
|
|
# client test against our own server - GOOD CERTS
|
|
./examples/server/server -c certs/ocsp/server3-cert.pem \
|
|
-k certs/ocsp/server3-key.pem -R "$ready_file5" \
|
|
-p "$port5" -u -v 4 &
|
|
server_pid5=$!
|
|
sleep 0.2
|
|
./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1 -u -v 4 \
|
|
-p "$port5"
|
|
RESULT=$?
|
|
[ "$RESULT" -ne 0 ] && printf '\n\n%s\n' "Client connection 1 failed" && exit 1
|
|
printf '%s\n\n' "Test PASSED!"
|
|
|
|
printf '%s\n\n' "------------- TEST CASE DTLS-2 SHOULD REVOKE --------------"
|
|
# client test against our own server - REVOKED SERVER CERT
|
|
remove_single_rF "$ready_file5"
|
|
./examples/server/server -c certs/ocsp/server4-cert.pem \
|
|
-k certs/ocsp/server4-key.pem -R "$ready_file5" \
|
|
-p "$port5" -v 4 &
|
|
server_pid5=$!
|
|
sleep 0.2
|
|
./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1 -v 4 \
|
|
-p "$port5"
|
|
RESULT=$?
|
|
[ "$RESULT" -ne 1 ] && printf '\n\n%s\n' "Client connection succeeded $RESULT" && exit 1
|
|
printf '%s\n\n' "Test successfully REVOKED!"
|
|
|
|
fi
|
|
|
|
printf '%s\n\n' "------------------- TESTS COMPLETE ---------------------------"
|
|
|
|
exit 0
|