From ebcab3571c5e7c1742cd68f4a603c7eac7c80129 Mon Sep 17 00:00:00 2001 From: Marius Burkard Date: Thu, 24 Sep 2020 14:59:28 +0200 Subject: [PATCH] - Do not try to issue a certificate a second time --- install/install.php | 5 ++++- install/lib/installer_base.lib.php | 10 ++++++++-- install/update.php | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/install/install.php b/install/install.php index 4437bd8fa3..ee455dbca8 100644 --- a/install/install.php +++ b/install/install.php @@ -537,6 +537,7 @@ if($force) { } //** Configure ISPConfig :-) +$issue_tried = false; $install_ispconfig_interface_default = ($conf['mysql']['master_slave_setup'] == 'y')?'n':'y'; if($install_mode == 'standard' || strtolower($inst->simple_query('Install ISPConfig Web Interface', array('y', 'n'), $install_ispconfig_interface_default,'install_ispconfig_web_interface')) == 'y') { swriteln('Installing ISPConfig'); @@ -563,6 +564,7 @@ if($install_mode == 'standard' || strtolower($inst->simple_query('Install ISPCon if(strtolower($inst->simple_query('Do you want a secure (SSL) connection to the ISPConfig web interface', array('y', 'n'), 'y','ispconfig_use_ssl')) == 'y') { $inst->make_ispconfig_ssl_cert(); + $issue_tried = true; } $inst->install_ispconfig_interface = true; @@ -572,8 +574,9 @@ if($install_mode == 'standard' || strtolower($inst->simple_query('Install ISPCon // Create SSL certs for non-webserver(s)? if(!file_exists('/usr/local/ispconfig/interface/ssl/ispserver.crt')) { - if(strtolower($inst->simple_query('Do you want to create SSL certs for your server?', array('y', 'n'), 'y')) == 'y') + if(!$issue_tried && strtolower($inst->simple_query('Do you want to create SSL certs for your server?', array('y', 'n'), 'y')) == 'y') { $inst->make_ispconfig_ssl_cert(); + } } else { swriteln('Certificate exists. Not creating a new one.'); } diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 9ac5c788f0..f07eadff71 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -2838,12 +2838,18 @@ class installer_base { } swriteln('Using certificate path ' . $acme_cert_dir); + $ip_address_match = false; if(!(($svr_ip4 && in_array($svr_ip4, $dns_ips)) || ($svr_ip6 && in_array($svr_ip6, $dns_ips)))) { swriteln('Server\'s public ip(s) (' . $svr_ip4 . ($svr_ip6 ? ', ' . $svr_ip6 : '') . ') not found in A/AAAA records for ' . $hostname . ': ' . implode(', ', $dns_ips)); + if(strtolower($inst->simple_query('Ignore DNS check and continue to request certificate?', array('y', 'n') , 'n','ignore_hostname_dns')) == 'y') { + $ip_address_match = true; + } + } else { + $ip_address_match = true; } - if ((!@is_dir($acme_cert_dir) || !@file_exists($check_acme_file) || !@file_exists($ssl_crt_file) || md5_file($check_acme_file) != md5_file($ssl_crt_file)) && (($svr_ip4 && in_array($svr_ip4, $dns_ips)) || ($svr_ip6 && in_array($svr_ip6, $dns_ips)))) { + if ((!@is_dir($acme_cert_dir) || !@file_exists($check_acme_file) || !@file_exists($ssl_crt_file) || md5_file($check_acme_file) != md5_file($ssl_crt_file)) && $ip_address_match == true) { // This script is needed earlier to check and open http port 80 or standalone might fail // Make executable and temporary symlink latest letsencrypt pre, post and renew hook script before install @@ -3002,7 +3008,7 @@ class installer_base { if($conf['apache']['installed'] == true) { $this->make_acme_vhost($hostname, 'apache', false); // we need this config file but we don't want apache to be restarted at this point } - if(($svr_ip4 && in_array($svr_ip4, $dns_ips)) || ($svr_ip6 && in_array($svr_ip6, $dns_ips))) { + if($ip_address_match) { // the directory already exists so we have to assume that it was created previously $issued_successfully = true; } diff --git a/install/update.php b/install/update.php index 1b6331f7da..517f78cf4f 100644 --- a/install/update.php +++ b/install/update.php @@ -519,6 +519,7 @@ if($reconfigure_services_answer == 'yes' || $reconfigure_services_answer == 'sel //** Configure ISPConfig swriteln('Updating ISPConfig'); +$issue_tried = false; if ($inst->install_ispconfig_interface) { //** Customise the port ISPConfig runs on $ispconfig_port_number = get_ispconfig_port_number(); @@ -533,13 +534,15 @@ if ($inst->install_ispconfig_interface) { // $ispconfig_ssl_default = (is_ispconfig_ssl_enabled() == true)?'y':'n'; if(strtolower($inst->simple_query('Create new ISPConfig SSL certificate', array('yes', 'no'), 'no','create_new_ispconfig_ssl_cert')) == 'yes') { $inst->make_ispconfig_ssl_cert(); + $issue_tried = true; } } // Create SSL certs for non-webserver(s)? if(!file_exists('/usr/local/ispconfig/interface/ssl/ispserver.crt')) { - if(strtolower($inst->simple_query('Do you want to create SSL certs for your server?', array('y', 'n'), 'y')) == 'y') + if(!$issue_tried && strtolower($inst->simple_query('Do you want to create SSL certs for your server?', array('y', 'n'), 'y')) == 'y') { $inst->make_ispconfig_ssl_cert(); + } } else { swriteln('Certificate exists. Not creating a new one.'); } -- GitLab