From 6137a98b195e1271bfeafe5edd06e1f57d42f26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20He=C4=8Da?= Date: Sat, 7 Apr 2018 07:42:26 +0200 Subject: [PATCH] fix for new openssl format Backward compatible, tested on ubuntu 16.04 with standard openssl and new from ppa. --- checkssl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checkssl b/checkssl index f09c652..125b0d3 100755 --- a/checkssl +++ b/checkssl @@ -371,10 +371,10 @@ while IFS= read -r LINE; do debug " --------------- domain ${DOMAIN}:${PORT} ${REMOTE_EXTRA}---------------------" # shellcheck disable=SC2086 CERTINFO=$(echo | openssl s_client -servername "${DOMAIN}" -connect "${DOMAIN}:${PORT}" ${REMOTE_EXTRA} 2>/dev/null | openssl x509 2>/dev/null) - ISSUEDTO=$(echo "$CERTINFO" | openssl x509 -noout -subject 2>/dev/null| grep -Eo "/CN=[^/]+" | cut -c 5-) + ISSUEDTO=$(echo "$CERTINFO" | openssl x509 -noout -subject -nameopt multiline 2>/dev/null| grep commonName | grep -Eo '=.*' | cut -c 3-) [[ -z $ISSUEDTO ]] && ISSUEDTO="-" debug "$ISSUEDTO" - ISSUER=$(echo "$CERTINFO" | openssl x509 -noout -issuer 2>/dev/null| grep -Eo "/CN=[a-zA-Z' 0-9]*"| cut -c 5-) + ISSUER=$(echo "$CERTINFO" | openssl x509 -noout -issuer -nameopt multiline 2>/dev/null| grep commonName | grep -Eo '=.*' | cut -c 3-) [[ -z $ISSUER ]] && ISSUER="-" debug "$ISSUER" ENDDATE=$(echo "$CERTINFO" | openssl x509 -noout -enddate 2>/dev/null| cut -d= -f 2-)