Skip to content

Commit c02f5e6

Browse files
authored
Regenerate LetsEncrypt certs when aliases change. (hestiacp#1353)
1 parent e987006 commit c02f5e6

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

web/edit/web/index.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,40 @@
270270
}
271271
}
272272
}
273-
}
273+
}
274+
275+
// Regenerate LE if aliases are different
276+
if ((!empty($_POST['v_ssl'])) && ( $v_letsencrypt == 'yes' ) && (!empty($_POST['v_letsencrypt'])) && empty($_SESSION['error_msg'])) {
277+
278+
// If aliases are different from stored aliases
279+
if (array_diff($valiases,$aliases) || array_diff($aliases,$valiases)) {
280+
281+
// Add certificate with new aliases
282+
$l_aliases = str_replace("\n", ',', $v_aliases);
283+
exec (HESTIA_CMD."v-add-letsencrypt-domain ".$user." ".escapeshellarg($v_domain)." ".escapeshellarg($l_aliases)." ''", $output, $return_var);
284+
check_return_code($return_var,$output);
285+
unset($output);
286+
$v_letsencrypt = 'yes';
287+
$v_ssl = 'yes';
288+
$restart_web = 'yes';
289+
$restart_proxy = 'yes';
290+
291+
exec (HESTIA_CMD."v-list-web-domain-ssl ".$user." ".escapeshellarg($v_domain)." json", $output, $return_var);
292+
$ssl_str = json_decode(implode('', $output), true);
293+
unset($output);
294+
$v_ssl_crt = $ssl_str[$v_domain]['CRT'];
295+
$v_ssl_key = $ssl_str[$v_domain]['KEY'];
296+
$v_ssl_ca = $ssl_str[$v_domain]['CA'];
297+
$v_ssl_subject = $ssl_str[$v_domain]['SUBJECT'];
298+
$v_ssl_aliases = $ssl_str[$v_domain]['ALIASES'];
299+
$v_ssl_not_before = $ssl_str[$v_domain]['NOT_BEFORE'];
300+
$v_ssl_not_after = $ssl_str[$v_domain]['NOT_AFTER'];
301+
$v_ssl_signature = $ssl_str[$v_domain]['SIGNATURE'];
302+
$v_ssl_pub_key = $ssl_str[$v_domain]['PUB_KEY'];
303+
$v_ssl_issuer = $ssl_str[$v_domain]['ISSUER'];
304+
}
305+
}
306+
274307
if ((!empty($v_stats)) && ($_POST['v_stats'] == $v_stats) && (empty($_SESSION['error_msg']))) {
275308
// Update statistics configuration when changing domain aliases
276309
$v_stats = escapeshellarg($_POST['v_stats']);

web/templates/admin/edit_web.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@
9696
<textarea size="20" class="vst-textinput short" name="v_aliases"><?=htmlentities(trim($v_aliases, "'"))?></textarea>
9797
</td>
9898
</tr>
99+
<tr>
100+
<td>
101+
<span class="alert alert-info alert-with-icon">
102+
<i class="fas fa-exclamation"></i>
103+
<?php print _('Changes to Aliases will cause Lets Encrypt to obtain a new SSL certificate if enabled.');?>
104+
</span>
105+
</td>
106+
</tr>
99107
<tr>
100108
<td class="vst-text step-top">
101109
<?php print _('Web Statistics');?>

web/templates/user/edit_web.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@
109109
<textarea size="20" class="vst-textinput short" name="v_aliases"><?=htmlentities(trim($v_aliases, "'"))?></textarea>
110110
</td>
111111
</tr>
112+
<tr>
113+
<td>
114+
<span class="alert alert-info alert-with-icon">
115+
<i class="fas fa-exclamation"></i>
116+
<?php print _('Changes to Aliases will cause Lets Encrypt to obtain a new SSL certificate if enabled.');?>
117+
</span>
118+
</td>
119+
</tr>
112120
<tr>
113121
<td class="vst-text step-top">
114122
<?php print _('Web Statistics');?>

0 commit comments

Comments
 (0)