Skip to content

Commit 8a1f4cf

Browse files
author
Till Brehm
committed
Do not add www as subdomain to a letsencrypt ssl cert when the domain of the webiste is already www.example.com (and not example.com) even if auto subdomain is set to www.
1 parent 1189fe2 commit 8a1f4cf

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

server/plugins-available/apache2_plugin.inc.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ function update($event_name, $data) {
11891189
$sub_prefixes = array();
11901190

11911191
//* be sure to have good domain
1192-
if($data['new']['subdomain'] == "www" OR $data['new']['subdomain'] == "*") {
1192+
if(substr($domain,0,4) != 'www.' && ($data['new']['subdomain'] == "www" OR $data['new']['subdomain'] == "*")) {
11931193
$temp_domains[] = "www." . $domain;
11941194
}
11951195

@@ -1207,7 +1207,7 @@ function update($event_name, $data) {
12071207
if(is_array($aliasdomains)) {
12081208
foreach($aliasdomains as $aliasdomain) {
12091209
$temp_domains[] = $aliasdomain['domain'];
1210-
if(isset($aliasdomain['subdomain']) && ($aliasdomain['subdomain'] != "none")) {
1210+
if(isset($aliasdomain['subdomain']) && substr($aliasdomain['domain'],0,4) != 'www.' && ($aliasdomain['subdomain'] == "www" OR $aliasdomain['subdomain'] == "*")) {
12111211
$temp_domains[] = "www." . $aliasdomain['domain'];
12121212
}
12131213
}
@@ -1234,6 +1234,7 @@ function update($event_name, $data) {
12341234
//if(!file_exists($crt_tmp_file) && !file_exists($key_tmp_file)) {
12351235
// we must not skip if cert exists, otherwise changed domains (alias or sub) won't make it to the cert
12361236
$app->log("Create Let's Encrypt SSL Cert for: $domain", LOGLEVEL_DEBUG);
1237+
$app->log("Let's Encrypt SSL Cert domains: $lddomain", LOGLEVEL_DEBUG);
12371238

12381239
$success = false;
12391240
$letsencrypt = explode("\n", shell_exec('which letsencrypt certbot /root/.local/share/letsencrypt/bin/letsencrypt'));

server/plugins-available/nginx_plugin.inc.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ function update($event_name, $data) {
12631263
$sub_prefixes = array();
12641264

12651265
//* be sure to have good domain
1266-
if($data['new']['subdomain'] == "www" OR $data['new']['subdomain'] == "*") {
1266+
if(substr($domain,0,4) != 'www.' && ($data['new']['subdomain'] == "www" OR $data['new']['subdomain'] == "*")) {
12671267
$temp_domains[] = "www." . $domain;
12681268
}
12691269

@@ -1281,7 +1281,7 @@ function update($event_name, $data) {
12811281
if(is_array($aliasdomains)) {
12821282
foreach($aliasdomains as $aliasdomain) {
12831283
$temp_domains[] = $aliasdomain['domain'];
1284-
if(isset($aliasdomain['subdomain']) && ($aliasdomain['subdomain'] != "none")) {
1284+
if(isset($aliasdomain['subdomain']) && substr($aliasdomain['domain'],0,4) != 'www.' && ($aliasdomain['subdomain'] == "www" OR $aliasdomain['subdomain'] == "*")) {
12851285
$temp_domains[] = "www." . $aliasdomain['domain'];
12861286
}
12871287

@@ -1313,6 +1313,7 @@ function update($event_name, $data) {
13131313
//if(!file_exists($crt_tmp_file) && !file_exists($key_tmp_file)) {
13141314
// we must not skip if cert exists, otherwise changed domains (alias or sub) won't make it to the cert
13151315
$app->log("Create Let's Encrypt SSL Cert for: $domain", LOGLEVEL_DEBUG);
1316+
$app->log("Let's Encrypt SSL Cert domains: $lddomain", LOGLEVEL_DEBUG);
13161317

13171318
$success = false;
13181319
$letsencrypt = explode("\n", shell_exec('which letsencrypt certbot /root/.local/share/letsencrypt/bin/letsencrypt'));

0 commit comments

Comments
 (0)