Skip to content

Commit 5f31eb1

Browse files
author
Till Brehm
committed
Merge branch '5743-improve-ssl-error-messages-on-install-update' into 'develop'
Resolve "Improve SSL error messages on install / update" Closes #5743 See merge request ispconfig/ispconfig3!1181
2 parents ca5966f + ff439a7 commit 5f31eb1

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

install/install.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@
574574
if(!file_exists('/usr/local/ispconfig/interface/ssl/ispserver.crt')) {
575575
if(strtolower($inst->simple_query('Do you want to create SSL certs for your server?', array('y', 'n'), 'y')) == 'y')
576576
$inst->make_ispconfig_ssl_cert();
577+
} else {
578+
swriteln('Certificate exists. Not creating a new one.');
577579
}
578580

579581
if($conf['services']['web'] == true) {

install/lib/installer_base.lib.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,6 +2822,8 @@ public function make_ispconfig_ssl_cert() {
28222822

28232823
// Request for certs if no LE SSL folder for server fqdn exist
28242824

2825+
swriteln('Checking / creating certificate for ' . $hostname);
2826+
28252827
$acme_cert_dir = '/usr/local/ispconfig/server/scripts/' . $hostname;
28262828
$check_acme_file = $acme_cert_dir . '/' . $hostname . '.cer';
28272829
if(!@is_dir($acme_cert_dir)) {
@@ -2832,6 +2834,13 @@ public function make_ispconfig_ssl_cert() {
28322834
$check_acme_file = $acme_cert_dir . '/cert.pem';
28332835
}
28342836
}
2837+
2838+
swriteln('Using certificate path ' . $acme_cert_dir);
2839+
if(!(($svr_ip4 && in_array($svr_ip4, $dns_ips)) || ($svr_ip6 && in_array($svr_ip6, $dns_ips)))) {
2840+
swriteln('Server\'s public ip(s) (' . $svr_ip4 . ($svr_ip6 ? ', ' . $svr_ip6 : '') . ') not found in A/AAAA records for ' . $hostname . ': ' . implode(', ', $dns_ips));
2841+
}
2842+
2843+
28352844
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)))) {
28362845

28372846
// This script is needed earlier to check and open http port 80 or standalone might fail
@@ -2881,8 +2890,10 @@ public function make_ispconfig_ssl_cert() {
28812890

28822891
// first of all create the acme vhosts if not existing
28832892
if($conf['nginx']['installed'] == true) {
2893+
swriteln('Using nginx for certificate validation');
28842894
$this->make_acme_vhost($hostname, 'nginx');
28852895
} elseif($conf['apache']['installed'] == true) {
2896+
swriteln('Using apache for certificate validation');
28862897
if($this->is_update == false && @is_link($vhost_conf_enabled_dir.'/000-ispconfig.conf')) {
28872898
$restore_conf_symlink = true;
28882899
unlink($vhost_conf_enabled_dir.'/000-ispconfig.conf');
@@ -2909,6 +2920,7 @@ public function make_ispconfig_ssl_cert() {
29092920
if($ret == 0 || ($ret == 2 && file_exists($check_acme_file))) {
29102921
// acme.sh returns with 2 on issue for already existing certificate
29112922

2923+
29122924
// Backup existing ispserver ssl files
29132925
if(file_exists($ssl_crt_file) || is_link($ssl_crt_file)) {
29142926
rename($ssl_crt_file, $ssl_crt_file . '-' . $date->format('YmdHis') . '.bak');
@@ -2926,6 +2938,8 @@ public function make_ispconfig_ssl_cert() {
29262938
$acme_chain = "--fullchain-file " . escapeshellarg($ssl_crt_file);
29272939
exec("$acme --install-cert -d $hostname $acme_key $acme_chain");
29282940
$issued_successfully = true;
2941+
} else {
2942+
swriteln('Issuing certificate via acme.sh failed. Please check that your hostname can be verified by letsencrypt');
29292943
}
29302944
// Else, we attempt to use the official LE certbot client certbot
29312945
} else {
@@ -2969,7 +2983,11 @@ public function make_ispconfig_ssl_cert() {
29692983
}
29702984

29712985
$issued_successfully = true;
2986+
} else {
2987+
swriteln('Issuing certificate via certbot failed. Please check log files and make sure that your hostname can be verified by letsencrypt');
29722988
}
2989+
} else {
2990+
swriteln('Did not find any valid acme client (acme.sh or certbot)');
29732991
}
29742992
}
29752993

@@ -2985,6 +3003,12 @@ public function make_ispconfig_ssl_cert() {
29853003

29863004
// If the LE SSL certs for this hostname exists
29873005
if(!is_dir($acme_cert_dir) || !file_exists($check_acme_file) || !$issued_successfully) {
3006+
if(!$issued_successfully) {
3007+
swriteln('Could not issue letsencrypt certificate, falling back to self-signed.');
3008+
} else {
3009+
swriteln('Issuing certificate seems to have succeeded but ' . $check_acme_file . ' seems to be missing. Falling back to self-signed.');
3010+
}
3011+
29883012
// We can still use the old self-signed method
29893013
$ssl_pw = substr(md5(mt_rand()), 0, 6);
29903014
exec("openssl genrsa -des3 -passout pass:$ssl_pw -out $ssl_key_file 4096");

install/update.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,30 @@
3030

3131
/*
3232
ISPConfig 3 updater.
33-
33+
3434
-------------------------------------------------------------------------------------
3535
- Interactive update
3636
-------------------------------------------------------------------------------------
3737
run:
38-
38+
3939
php update.php
40-
40+
4141
-------------------------------------------------------------------------------------
4242
- Noninteractive (autoupdate) mode
4343
-------------------------------------------------------------------------------------
44-
44+
4545
The autoupdate mode can read the updater questions from a .ini style file or from
46-
a php config file. Examples for both file types are in the docs folder.
46+
a php config file. Examples for both file types are in the docs folder.
4747
See autoinstall.ini.sample and autoinstall.conf_sample.php.
48-
48+
4949
run:
50-
50+
5151
php update.php --autoinstall=autoinstall.ini
52-
52+
5353
or
54-
54+
5555
php update.php --autoinstall=autoinstall.conf.php
56-
56+
5757
*/
5858

5959
error_reporting(E_ALL|E_STRICT);
@@ -263,7 +263,7 @@
263263
do {
264264
$tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host'],'mysql_master_hostname');
265265
$tmp_mysql_server_port = $inst->free_query('MySQL master server port', $conf['mysql']['master_port'],'mysql_master_port');
266-
$tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user'],'mysql_master_root_user');
266+
$tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user'],'mysql_master_root_user');
267267
$tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password'],'mysql_master_root_password');
268268
$tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database'],'mysql_master_database');
269269

@@ -474,7 +474,7 @@
474474
$inst->configure_apps_vhost();
475475
} else swriteln('Skipping config of Apps vhost');
476476
}
477-
477+
478478
//* Configure Jailkit
479479
if($inst->reconfigure_app('Jailkit', $reconfigure_services_answer)) {
480480
swriteln('Configuring Jailkit');
@@ -540,6 +540,8 @@
540540
if(!file_exists('/usr/local/ispconfig/interface/ssl/ispserver.crt')) {
541541
if(strtolower($inst->simple_query('Do you want to create SSL certs for your server?', array('y', 'n'), 'y')) == 'y')
542542
$inst->make_ispconfig_ssl_cert();
543+
} else {
544+
swriteln('Certificate exists. Not creating a new one.');
543545
}
544546

545547
$inst->install_ispconfig();

0 commit comments

Comments
 (0)