From 2dbc5259255f2cd4b718da5fb641872833945617 Mon Sep 17 00:00:00 2001 From: mrflos Date: Fri, 21 Apr 2023 09:23:10 +0300 Subject: [PATCH] fix(yeswiki-installer) : no www. for subdomain certs --- utils.inc.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils.inc.php b/utils.inc.php index 70747ca..430887b 100644 --- a/utils.inc.php +++ b/utils.inc.php @@ -195,6 +195,7 @@ function createNginxConfig($domain, $user, $herseUser, $hersePass, $nossl) } $templates = new League\Plates\Engine(dirname(__FILE__).'/templates'); $subDomain = preg_match('/.'.$_SERVER['maindomain'].'$/isU', $domain, $matches, PREG_OFFSET_CAPTURE, 0); + $isFullDomain = !preg_match('/^([a-zA-Z0-9]([-a-zA-Z0-9]{0,61}[a-zA-Z0-9])\.)([a-zA-Z0-9]{1,2}([-a-zA-Z0-9]{0,252}[a-zA-Z0-9])?)\.([a-zA-Z]{2,63})$/isU', $domain, $matches, PREG_OFFSET_CAPTURE, 0); if (!$nossl) { if (!$subDomain) { file_put_contents( @@ -208,7 +209,11 @@ function createNginxConfig($domain, $user, $herseUser, $hersePass, $nossl) ) ); exec('service nginx force-reload', $output); - exec('/root/.acme.sh/acme.sh --issue -d '.$domain.' -d www.'.$domain.' -k ec-384 -w /home/'.$user.'/'.$domain.'/', $output); + if ($isFullDomain) { + exec('/root/.acme.sh/acme.sh --issue -d '.$domain.' -d www.'.$domain.' -k ec-384 -w /home/'.$user.'/'.$domain.'/', $output); + } else { + exec('/root/.acme.sh/acme.sh --issue -d '.$domain.' -k ec-384 -w /home/'.$user.'/'.$domain.'/', $output); + } exec('mkdir -p /etc/letsencrypt/live/'.$domain, $output); exec('/root/.acme.sh/acme.sh --install-cert -d '.$domain.' --ecc \ --cert-file /etc/letsencrypt/live/'.$domain.'/cert.pem \