From 1dcdb097b59f48c19b05da9a74e18e575b04292b Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Thu, 21 Mar 2024 12:34:28 +0100
Subject: [PATCH] faster check if certificate exists

---
 cm.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/cm.sh b/cm.sh
index ff558e3..28b9ab7 100755
--- a/cm.sh
+++ b/cm.sh
@@ -102,7 +102,8 @@ function _listCertdomains(){
 # used in _certMustExist, _certMustNotExist
 # param  string  FQDN
 function _certExists(){
-	_listCertdomains | grep "^${CM_fqdn}$" >/dev/null
+	# _listCertdomains | grep "^${CM_fqdn}$" >/dev/null
+	$ACME --info -d "${CM_fqdn}" 2>/dev/null | grep "letsencrypt.org" >/dev/null
 }
 
 # internal function; a certificate of a given FQDN must exist - otherwise
@@ -284,7 +285,7 @@ function _getAliases(){
 	_sortWords $(
 		openssl x509 -noout -text -in ${CM_outfile_cert} \
 			| grep -E "(DNS:)" \
-			| sed "s#^\ *##g"  \
+			| sed "s#^ *##g"  \
 			| sed "s#DNS:##g"  \
 			| sed "s#,##g"
 	)
-- 
GitLab