From ee22d27cf8cd72f29548c73cfcb1521f8edb519a Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Sun, 11 Apr 2021 20:48:18 +0700 Subject: [PATCH] add sanity check that engine can be loaded --- scripts/openssl.test | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/scripts/openssl.test b/scripts/openssl.test index 93f49e658..1823d9ccc 100755 --- a/scripts/openssl.test +++ b/scripts/openssl.test @@ -4,7 +4,7 @@ # Enviornment variables used: # OPENSSL (openssl app to use) -# OPENSSL_ENGINE_ID (engine id if any i.e. -engine wolfengine) +# OPENSSL_ENGINE_ID (engine id if any i.e. "wolfengine") CERT_DIR="$PWD/$(dirname "$0")/../certs" @@ -133,6 +133,28 @@ start_openssl_server() { server_port=$port found_free_port=0 counter=0 + + # If OPENSSL_ENGINE_ID has been set then check that the desired engine can + # be loaded successfully and error out if not. Otherwise the OpenSSL app + # will fall back to default engine. + if [ ! -z "${OPENSSL_ENGINE_ID}" ]; then + OUTPUT=`$OPENSSL engine -tt $OPENSSL_ENGINE_ID` + if [ $? != 0 ]; then + printf "not able to load engine\n" + printf "$OPENSSL engine -tt $OPENSSL_ENGINE_ID\n" + do_cleanup + exit 1 + else + echo $OUTPUT | grep "available" + if [ $? != 0 ]; then + printf "engine not available\n" + do_cleanup + exit 1 + fi + fi + fi + OPENSSL_ENGINE_ID="-engine ${OPENSSL_ENGINE_ID}" + while [ "$counter" -lt 20 ]; do echo -e "\n# Trying to start $openssl_suite OpenSSL server on port $server_port..." echo "#"