From cc750142a912cf0fc51ff605362cd3c4078f4e30 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Thu, 25 May 2023 19:15:43 -0500 Subject: [PATCH] Update sites.inc --- inc/sites.inc | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/inc/sites.inc b/inc/sites.inc index 15c1d26e..ded56d1e 100755 --- a/inc/sites.inc +++ b/inc/sites.inc @@ -347,7 +347,7 @@ NEWSITE(){ if [ "${CREATE_SSL}" = "yes" ]; then echo -e " - ssl_certificate /etc/letsencrypt/live/${MAIN_SITE}/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/${MAIN_SITE}/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/${MAIN_SITE}/privkey.pem; include conf.d/include/ssl-ciphers.conf;" >> /etc/nginx/sites-available/${MAIN_SITE} fi @@ -502,7 +502,7 @@ SITEINFO(){ proxyhost='' fi - [ "$(grep ssl_certificate ${sitefile})" != "" ] && ssl='Yes' || ssl='' + [ "$(grep ssl_certificate_key ${sitefile})" != "" ] && ssl='Yes' || ssl='' [ "$(grep include/hsts-support.conf ${sitefile})" != "" ] && hsts='Yes' || hsts='' [ "$(grep include/websocket-support.conf ${sitefile})" != "" ] && wbskt='Yes' || wbskt='' [ "$(grep include/secure-access.conf ${sitefile})" != "" ] && lock='Yes' || lock='' @@ -541,10 +541,23 @@ SITEINFO(){ fi site=${SITELIST[${siteid}]} sitefile=${!gosite}/${site}.conf - echo $sitefile - if [ "$(grep ssl_certificate ${sitefile})" != "" ]; then + certpath=$(grep ssl_certificate_key ${sitefile}) + if [ "${certpath}" != "" ]; then ssl='Yes' - + certpath=${certpath%/*}; certpath=${certpath#* } + SUBJECT=$(openssl x509 -in ${certpath}/cert.pem -noout -subject|grep -oP '(?<=CN = )[^,]+'|sort -uV) + SUBJECTNAMES=$(openssl x509 -in ${certpath}/cert.pem -noout -text|grep -oP '(?<=DNS:|IP Address:)[^,]+'|sort -uV) + CERTEXPIRE=$(date -d "$(: | openssl x509 -in ${certpath}/cert.pem -text | grep 'Not After' |awk '{print $4,$5,$7}')" '+%s'); + if [ "${SUBJECTNAMES}" != "" ]; then + SUBJECTNAMES=${SUBJECTNAMES//$'\n'/, } + # SUBJECTNAMES=$(echo $${SUBJECTNAMES} | sed "s/\n/, /g") + SUBJECTNAMES=$(echo ${SUBJECTNAMES} | sed "s/${SUBJECT}, //g") + SUBJECTNAMES=$(echo ${SUBJECTNAMES} | sed "s/, ${SUBJECT}//g") + SUBJECTNAMES=$(echo ${SUBJECTNAMES} | sed "s/${SUBJECT}//g") + SSLNAMES="${SUBJECT}, ${SUBJECTNAMES}" + else + SSLNAMES="${SUBJECT}" + fi else ssl='-' fi @@ -552,11 +565,11 @@ SITEINFO(){ [ "$(grep include/websocket-support.conf ${sitefile})" != "" ] && wbskt='Yes' || wbskt='-' [ "$(grep include/secure-access.conf ${sitefile})" != "" ] && lock='Yes' || lock='-' - echo -e "${idsCL[Cyan]}!) Site: ${idsST[Bold]}${site}${idsST[Reset]}${idsCL[LightCyan]}" - echo -e "${idsCL[Cyan]}!) SSL: ${idsST[Bold]}${ssl}${idsST[Reset]}${idsCL[LightCyan]}" - echo -e "${idsCL[Cyan]}3) HSTS ${idsST[Bold]}${hsts}${idsST[Reset]}${idsCL[LightCyan]}" - echo -e "${idsCL[Cyan]}4) WbSkt: ${idsST[Bold]}${wbskt}${idsST[Reset]}${idsCL[LightCyan]}" - echo -e "${idsCL[Cyan]}5) Lock: ${idsST[Bold]}${lock}${idsST[Reset]}${idsCL[LightCyan]}" + echo -e "${idsCL[Cyan]}!) Site: ${idsST[Bold]}${site}${idsST[Reset]}" + echo -e "${idsCL[Cyan]}!) SSL: ${idsST[Bold]}${ssl}${idsST[Reset]} - ${idsCL[LightCyan]}${SSLNAMES}" + echo -e "${idsCL[Cyan]}3) HSTS ${idsST[Bold]}${hsts}${idsST[Reset]}" + echo -e "${idsCL[Cyan]}4) WbSkt: ${idsST[Bold]}${wbskt}${idsST[Reset]}" + echo -e "${idsCL[Cyan]}5) Lock: ${idsST[Bold]}${lock}${idsST[Reset]}" echo -en "\n${idsCL[LightCyan]}Enter the line number to edit: ${idsCL[Default]}" read edit echo