Update certs.inc

This commit is contained in:
2023-11-12 22:03:26 -06:00
parent 0b20c45e1b
commit 341c6276e8

View File

@@ -282,7 +282,7 @@ LISTCERTS(){
while [ "${editc^}" != "E" ]; do
echo -e "\033[K"
echo -e "\033[K"
echo -e "\033[K (${idsCL[Green]}R${idsCL[Default]})eload, (${idsCL[Red]}E${idsCL[Default]})xit"
echo -e "\033[K (${idsCL[Green]}R${idsCL[Default]})eload, (${idsCL[Yellow]}E${idsCL[Default]})xit"
echo -e "\033[K"
echo -e "\033[K"
echo -e "\033[K"
@@ -299,17 +299,33 @@ LISTCERTS(){
[ "${SEARCH}" != "0" ] && LISTCERTS -edit -search ${SEARCH} || LISTCERTS -edit
exit 0
elif [ "${CERTLIST[${siteid}]}" != "" ]; then
elif [ "${CERTLIST[${certid}]}" != "" ]; then
cert=${CERTLIST[${certid}]}
certdir=${NM_CERTPATH}/live/${cert}
SUBJECT=$(${NCMD} openssl x509 -in ${certdir}/cert.pem -noout -subject|grep -oP '(?<=CN = )[^,]+'|sort -uV)
SUBJECTNAMES=$(${NCMD} openssl x509 -in ${certdir}/cert.pem -noout -text|grep -oP '(?<=DNS:|IP Address:)[^,]+'|sort -uV)
CERTEXPIRE=$(date -d "$(: | ${NCMD} openssl x509 -in ${certdir}/cert.pem -text | grep 'Not After' |awk '{print $4,$5,$7}')" '+%s');
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")
IFS=', '; SUBJECT_NAMES=(${SUBJECTNAMES}); unset IFS
[[ "$(declare -p CHECKCERT_DOMAINS)" =~ "declare -a" ]] && [ "${CHECKCERT_DOMAINS[${SUBJECT}]}" = "" ] && monitored='-' || monitored="Yes"
until [ "${editc^}" = "C" ]; do
echo -e "\033[K${idsCL[White]} Expires: ${idsCL[Cyan]}${idsST[Bold]}${ssl}${idsST[Reset]}"
echo -e "\033[K${idsCL[White]} Cert Common Name: ${idsCL[Cyan]}${idsST[Bold]}${servernames}${idsST[Reset]}"
echo -e "\033[K${idsCL[White]}1) Cert Alt. Names: ${idsCL[Cyan]}${idsST[Bold]}${type}${idsST[Reset]}"
echo -e "\033[K${idsCL[White]}2) Monitored: ${idsCL[Cyan]}${idsST[Bold]}${hsts}${idsST[Reset]}"
echo -e "\033[K${idsCL[White]} Expires: ${idsCL[Cyan]}${idsST[Bold]}$(date -d @${CERTEXPIRE} '+%m-%d-%Y')${idsST[Reset]}"
echo -e "\033[K${idsCL[White]} Cert Common Name: ${idsCL[Cyan]}${idsST[Bold]}${SUBJECT}${idsST[Reset]}"
echo
echo -e "\033[K${idsCL[White]}1) Cert Alt. Names: ${idsCL[Cyan]}${idsST[Bold]}${SUBJECTNAMES}${idsST[Reset]}"
echo -e "\033[K${idsCL[White]}2) Monitored: ${idsCL[Cyan]}${idsST[Bold]}${monitored}${idsST[Reset]}"
if [ "${editc}" != "s" ]; then
echo -e "\033[K"
echo -e "\033[K"
echo -e "\033[K"
echo -e "\033[K (${idsCL[Green]}S${idsCL[Default]})ave, (${idsCL[Red]}D${idsCL[Default]})elete, (${idsCL[Red]}C${idsCL[Default]})ancel, (${idsCL[Red]}E${idsCL[Default]})xit"
echo -e "\033[K (${idsCL[Green]}S${idsCL[Default]})ave, (${idsCL[Red]}D${idsCL[Default]})elete, (${idsCL[Yellow]}C${idsCL[Default]})ancel, (${idsCL[Yellow]}E${idsCL[Default]})xit"
echo -e "\033[K"
echo -e "\033[K"
echo -e "\033[7A"