2015-07-21 13:56:47 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
#crl.test
|
|
|
|
|
|
2015-07-22 10:05:39 -06:00
|
|
|
log_file="scripts/client_result.txt"
|
2015-07-21 13:56:47 -06:00
|
|
|
success_line="err = -361, CRL Cert revoked"
|
2015-07-22 10:37:24 -06:00
|
|
|
exit_code=-1
|
2015-07-22 10:05:39 -06:00
|
|
|
|
|
|
|
|
crl_port=11113
|
2015-07-22 10:37:24 -06:00
|
|
|
#no_pid tells us process was never started if -1
|
2015-07-22 10:05:39 -06:00
|
|
|
no_pid=-1
|
2015-07-22 10:37:24 -06:00
|
|
|
#server_pid captured on startup, stores the id of the server process
|
2015-07-22 10:05:39 -06:00
|
|
|
server_pid=$no_pid
|
|
|
|
|
|
|
|
|
|
function remove_ready_file() {
|
|
|
|
|
if test -e /tmp/wolfssl_server_ready; then
|
|
|
|
|
echo -e "removing exisitng server_ready file"
|
|
|
|
|
rm /tmp/wolfssl_server_ready
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-22 10:37:24 -06:00
|
|
|
function remove_log_file() {
|
|
|
|
|
if test -e $log_file; then
|
|
|
|
|
echo -e "removing client log file"
|
|
|
|
|
rm $log_file
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-22 10:05:39 -06:00
|
|
|
# trap this function so if user aborts with ^C or other kill signal we still
|
|
|
|
|
# get an exit that will in turn clean up the file system
|
|
|
|
|
function abort_trap() {
|
2015-07-22 10:37:24 -06:00
|
|
|
exit_code=-2 #different exit code in case of user interrupt
|
2015-07-22 10:05:39 -06:00
|
|
|
echo "got abort signal, exiting with $exit_code"
|
|
|
|
|
exit $exit_code
|
|
|
|
|
}
|
|
|
|
|
trap abort_trap INT TERM
|
|
|
|
|
|
2015-07-21 13:56:47 -06:00
|
|
|
|
|
|
|
|
# trap this function so that if we exit on an error the file system will still
|
|
|
|
|
# be restored and the other tests may still pass. Never call this function
|
|
|
|
|
# instead use "exit <some value>" and this function will run automatically
|
|
|
|
|
function restore_file_system() {
|
2015-07-22 10:05:39 -06:00
|
|
|
echo "in cleanup"
|
|
|
|
|
|
|
|
|
|
if [ $server_pid != $no_pid ]
|
|
|
|
|
then
|
|
|
|
|
echo "killing server"
|
|
|
|
|
kill -9 $server_pid
|
|
|
|
|
fi
|
|
|
|
|
remove_ready_file
|
2015-07-22 10:37:24 -06:00
|
|
|
remove_log_file
|
2015-07-21 13:56:47 -06:00
|
|
|
}
|
|
|
|
|
trap restore_file_system EXIT
|
|
|
|
|
|
2015-07-22 10:05:39 -06:00
|
|
|
function run_test() {
|
|
|
|
|
echo -e "\nStarting example server for crl test...\n"
|
2015-07-21 13:56:47 -06:00
|
|
|
|
2015-07-22 10:05:39 -06:00
|
|
|
remove_ready_file
|
2015-07-22 10:37:24 -06:00
|
|
|
|
|
|
|
|
# starts the server on crl_port, -R generates ready file to be used as a
|
|
|
|
|
# mutex lock, -c loads the revoked certificate. We capture the processid
|
|
|
|
|
# into the variable server_pid
|
|
|
|
|
./examples/server/server -R -p $crl_port -c certs/server-revoked-cert.pem &
|
2015-07-22 10:05:39 -06:00
|
|
|
server_pid=$!
|
2015-07-21 13:56:47 -06:00
|
|
|
|
2015-07-22 10:05:39 -06:00
|
|
|
while [ ! -s /tmp/wolfssl_server_ready ]; do
|
|
|
|
|
echo -e "waiting for server_ready file..."
|
|
|
|
|
sleep 0.1
|
|
|
|
|
done
|
|
|
|
|
|
2015-07-22 10:37:24 -06:00
|
|
|
# starts client on crl_port and redirects output to log_file
|
2015-07-22 10:05:39 -06:00
|
|
|
./examples/client/client -p $crl_port &> $log_file
|
|
|
|
|
client_result=$?
|
|
|
|
|
|
2015-07-21 13:56:47 -06:00
|
|
|
if test -e $log_file
|
|
|
|
|
then
|
|
|
|
|
while read line;
|
|
|
|
|
do
|
|
|
|
|
if [[ "x$success_line" == "x$line" ]]
|
|
|
|
|
then
|
|
|
|
|
echo "Successful Revocation!!!!"
|
|
|
|
|
fi
|
|
|
|
|
done < $log_file
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
######### begin program #########
|
|
|
|
|
|
|
|
|
|
# run the test
|
|
|
|
|
run_test
|
2015-07-22 10:37:24 -06:00
|
|
|
exit_code=0
|
2015-07-21 13:56:47 -06:00
|
|
|
echo "exiting with $exit_code"
|
|
|
|
|
exit $exit_code
|
|
|
|
|
########## end program ##########
|