From 4b6bdf8cdf9643823642c90acef52c2de8a0dec5 Mon Sep 17 00:00:00 2001 From: David Cooper Date: Thu, 16 Jan 2020 13:41:27 -0500 Subject: [PATCH] More polishing of http basic auth * Replace "! -z" with "-n" * Replace "openssl' with "$OPENSSL" * Redirect stderr output of $OPENSSL to /dev/null to supress "WARNING: can't open config file: /usr/local/etc/ssl/openssl.cnf" message (see #833) * Remove unnecessary spaces from $GET_REQ11 string. --- testssl.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testssl.sh b/testssl.sh index 59fc711..407e0dc 100755 --- a/testssl.sh +++ b/testssl.sh @@ -18419,10 +18419,10 @@ determine_service() { $SNEAKY && \ ua="$UA_SNEAKY" || \ ua="$UA_STD" - if [[ ! -z "$BASICAUTH" ]]; then - basicauth_header="Authorization: Basic $(openssl base64 <<< $BASICAUTH) \r\n" + if [[ -n "$BASICAUTH" ]]; then + basicauth_header="Authorization: Basic $($OPENSSL base64 <<< "$BASICAUTH" 2>/dev/null)\r\n" fi - GET_REQ11="GET $URL_PATH HTTP/1.1\r\nHost: $NODE\r\nUser-Agent: $ua\r\n$basicauth_header Accept-Encoding: identity\r\nAccept: text/*\r\nConnection: Close\r\n\r\n" + GET_REQ11="GET $URL_PATH HTTP/1.1\r\nHost: $NODE\r\nUser-Agent: $ua\r\n${basicauth_header}Accept-Encoding: identity\r\nAccept: text/*\r\nConnection: Close\r\n\r\n" # returns always 0: service_detection $OPTIMAL_PROTO else # STARTTLS