From 00fb68f47c883e735ac2e3b1b0c1e88c0fa7d1c1 Mon Sep 17 00:00:00 2001 From: David Cooper Date: Mon, 25 Oct 2021 12:15:13 -0400 Subject: [PATCH] Fix s_client_options() This commit fixes an error in s_client_options() when the function is called with an empty "-cipher" list and $OPENSSL supports "@SECLEVEL". This happens, for example, when ciphers_by_strength() is called for TLS 1.3. The call to `openssl s_client` will fail is the cipher option is provided with an empty list or a list that just contains "@SECLEVEL=0". So, "@SECLEVEL=0" should only be added if the "$ciphers" list is non-empty. If "$ciphers" remains empty, then the "-cipher" option will not be added to the command line. --- testssl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testssl.sh b/testssl.sh index 370ec44..94eb444 100755 --- a/testssl.sh +++ b/testssl.sh @@ -2197,7 +2197,7 @@ s_client_options() { if "$HAS_SECLEVEL"; then if [[ "$ciphers" == notpresent ]]; then [[ ! " $options " =~ \ -tls1_3\ ]] && ciphers="@SECLEVEL=0:ALL:COMPLEMENTOFALL" - else + elif [[ -n "$ciphers" ]]; then ciphers="@SECLEVEL=0:$ciphers" fi fi