Skip to content

Commit 83246e6

Browse files
committed
set umask before calling acme.sh
1 parent 791d625 commit 83246e6

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

install/lib/installer_base.lib.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3023,6 +3023,9 @@ public function make_ispconfig_ssl_cert() {
30233023

30243024
swriteln('acme.sh is installed, overriding certificate path to use ' . $acme_cert_dir);
30253025

3026+
# acme.sh does not set umask, resulting in incorrect permissions (ispconfig issue #6015)
3027+
$old_umask = umask(0022);
3028+
30263029
$out = null;
30273030
$ret = null;
30283031
if($conf['nginx']['installed'] == true || $conf['apache']['installed'] == true) {
@@ -3044,6 +3047,7 @@ public function make_ispconfig_ssl_cert() {
30443047
$acme_chain = "--fullchain-file " . escapeshellarg($ssl_crt_file);
30453048
exec("$acme --install-cert -d " . escapeshellarg($hostname) . " $acme_key $acme_chain");
30463049
$issued_successfully = true;
3050+
umask($old_umask);
30473051

30483052
// Make temporary backup of self-signed certs permanent
30493053
if(file_exists($ssl_crt_file.'-temporary.bak') || is_link($ssl_crt_file.'-temporary.bak'))
@@ -3056,6 +3060,8 @@ public function make_ispconfig_ssl_cert() {
30563060
} else {
30573061
swriteln('Issuing certificate via acme.sh failed. Please check that your hostname can be verified by letsencrypt');
30583062

3063+
umask($old_umask);
3064+
30593065
// Restore temporary backup of self-signed certs
30603066
if(file_exists($ssl_crt_file.'-temporary.bak') || is_link($ssl_crt_file.'-temporary.bak'))
30613067
rename($ssl_crt_file.'-temporary.bak', $ssl_crt_file);

server/lib/classes/letsencrypt.inc.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,13 @@ public function request_certificates($data, $server_type = 'apache') {
399399
$this->certbot_use_certcommand = false;
400400
$letsencrypt_cmd = '';
401401
$allow_return_codes = null;
402+
$old_umask = umask(0022); # work around acme.sh permission bug, see #6015
402403
if($use_acme) {
403404
$letsencrypt_cmd = $this->get_acme_command($temp_domains, $key_file, $bundle_file, $crt_file, $server_type);
404405
$allow_return_codes = array(2);
405406
} else {
406407
$letsencrypt_cmd = $this->get_certbot_command($temp_domains);
408+
umask($old_umask);
407409
}
408410

409411
$success = false;
@@ -420,6 +422,7 @@ public function request_certificates($data, $server_type = 'apache') {
420422
}
421423

422424
if($use_acme === true) {
425+
umask($old_umask);
423426
if(!$success) {
424427
$app->log('Let\'s Encrypt SSL Cert for: ' . $domain . ' could not be issued.', LOGLEVEL_WARN);
425428
$app->log($letsencrypt_cmd, LOGLEVEL_WARN);

0 commit comments

Comments
 (0)