From 3b184b115bc15e9a2ad14b6d7e8a744355b72894 Mon Sep 17 00:00:00 2001 From: earnolmartin Date: Mon, 9 Jan 2023 15:53:23 -0700 Subject: [PATCH] Remove Let's Encrypt Certs for Subdomains as well if Domain SSL Settings Are Reset --- ehcp/classapp.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ehcp/classapp.php b/ehcp/classapp.php index b4d92a5..6b2399d 100755 --- a/ehcp/classapp.php +++ b/ehcp/classapp.php @@ -7806,6 +7806,18 @@ function deleteDomainDirect($domainname,$syncdomains=True){ function removeLetsEncryptCertificates($domains){ $success = true; foreach($domains as $domain){ + // Get subdomains as well + $subdoms=$this->getSubDomains("domainname = '" . $domain . "'"); + if(is_array($subdoms) && count($subdoms) > 0){ + foreach($subdoms as $subdom){ + $fullDomain = $subdom["subdomain"] . "." . $subdom["domainname"]; + $this->runCommandInDaemon("/usr/local/bin/certbot delete --cert-name " . $fullDomain); + $this->bashDelete("/etc/letsencrypt/live/" . $fullDomain, true); + $this->bashDelete("/etc/letsencrypt/archive/" . $fullDomain, true); + $this->bashDelete("/etc/letsencrypt/renewal/" . $fullDomain . ".conf", true); + } + } + // Actually run the delete operation from certbot to handle any additional cleanup $this->runCommandInDaemon("/usr/local/bin/certbot delete --cert-name " . $domain);