@@ -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 " );
0 commit comments