@@ -33,7 +33,6 @@ class installer_base {
3333 var $ wb = array ();
3434 var $ language = 'en ' ;
3535 var $ db ;
36- public $ conf ;
3736 public $ install_ispconfig_interface = true ;
3837 public $ is_update = false ; // true if it is an update, falsi if it is a new install
3938 public $ min_php = '5.3.3 ' ; // minimal php-version for update / install
@@ -42,7 +41,6 @@ class installer_base {
4241
4342 public function __construct () {
4443 global $ conf ; //TODO: maybe $conf should be passed to constructor
45- //$this->conf = $conf;
4644 }
4745
4846 //: TODO Implement the translation function and language files for the installer.
@@ -2822,6 +2820,8 @@ public function make_ispconfig_ssl_cert() {
28222820
28232821 // Request for certs if no LE SSL folder for server fqdn exist
28242822
2823+ swriteln ('Checking / creating certificate for ' . $ hostname );
2824+
28252825 $ acme_cert_dir = '/usr/local/ispconfig/server/scripts/ ' . $ hostname ;
28262826 $ check_acme_file = $ acme_cert_dir . '/ ' . $ hostname . '.cer ' ;
28272827 if (!@is_dir ($ acme_cert_dir )) {
@@ -2832,6 +2832,13 @@ public function make_ispconfig_ssl_cert() {
28322832 $ check_acme_file = $ acme_cert_dir . '/cert.pem ' ;
28332833 }
28342834 }
2835+
2836+ swriteln ('Using certificate path ' . $ acme_cert_dir );
2837+ if (!(($ svr_ip4 && in_array ($ svr_ip4 , $ dns_ips )) || ($ svr_ip6 && in_array ($ svr_ip6 , $ dns_ips )))) {
2838+ swriteln ('Server \'s public ip(s) ( ' . $ svr_ip4 . ($ svr_ip6 ? ', ' . $ svr_ip6 : '' ) . ') not found in A/AAAA records for ' . $ hostname . ': ' . implode (', ' , $ dns_ips ));
2839+ }
2840+
2841+
28352842 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 )))) {
28362843
28372844 // This script is needed earlier to check and open http port 80 or standalone might fail
@@ -2881,8 +2888,10 @@ public function make_ispconfig_ssl_cert() {
28812888
28822889 // first of all create the acme vhosts if not existing
28832890 if ($ conf ['nginx ' ]['installed ' ] == true ) {
2891+ swriteln ('Using nginx for certificate validation ' );
28842892 $ this ->make_acme_vhost ($ hostname , 'nginx ' );
28852893 } elseif ($ conf ['apache ' ]['installed ' ] == true ) {
2894+ swriteln ('Using apache for certificate validation ' );
28862895 if ($ this ->is_update == false && @is_link ($ vhost_conf_enabled_dir .'/000-ispconfig.conf ' )) {
28872896 $ restore_conf_symlink = true ;
28882897 unlink ($ vhost_conf_enabled_dir .'/000-ispconfig.conf ' );
@@ -2899,7 +2908,7 @@ public function make_ispconfig_ssl_cert() {
28992908 $ out = null ;
29002909 $ ret = null ;
29012910 if ($ conf ['nginx ' ]['installed ' ] == true || $ conf ['apache ' ]['installed ' ] == true ) {
2902- exec ("$ acme --issue -w /usr/local/ispconfig/interface/acme -d $ hostname $ renew_hook " , $ out , $ ret );
2911+ exec ("$ acme --issue -w /usr/local/ispconfig/interface/acme -d " . escapeshellarg ( $ hostname) . " $ renew_hook " , $ out , $ ret );
29032912 }
29042913 // Else, it is not webserver, so we use standalone
29052914 else {
@@ -2909,6 +2918,7 @@ public function make_ispconfig_ssl_cert() {
29092918 if ($ ret == 0 || ($ ret == 2 && file_exists ($ check_acme_file ))) {
29102919 // acme.sh returns with 2 on issue for already existing certificate
29112920
2921+
29122922 // Backup existing ispserver ssl files
29132923 if (file_exists ($ ssl_crt_file ) || is_link ($ ssl_crt_file )) {
29142924 rename ($ ssl_crt_file , $ ssl_crt_file . '- ' . $ date ->format ('YmdHis ' ) . '.bak ' );
@@ -2924,8 +2934,10 @@ public function make_ispconfig_ssl_cert() {
29242934 //$acme_cert = "--cert-file $acme_cert_dir/cert.pem";
29252935 $ acme_key = "--key-file " . escapeshellarg ($ ssl_key_file );
29262936 $ acme_chain = "--fullchain-file " . escapeshellarg ($ ssl_crt_file );
2927- exec ("$ acme --install-cert -d $ hostname $ acme_key $ acme_chain " );
2937+ exec ("$ acme --install-cert -d " . escapeshellarg ( $ hostname) . " $ acme_key $ acme_chain " );
29282938 $ issued_successfully = true ;
2939+ } else {
2940+ swriteln ('Issuing certificate via acme.sh failed. Please check that your hostname can be verified by letsencrypt ' );
29292941 }
29302942 // Else, we attempt to use the official LE certbot client certbot
29312943 } else {
@@ -2947,11 +2959,11 @@ public function make_ispconfig_ssl_cert() {
29472959
29482960 // If this is a webserver
29492961 if ($ conf ['nginx ' ]['installed ' ] == true || $ conf ['apache ' ]['installed ' ] == true ) {
2950- exec ("$ le_client $ certonly $ acme_version --authenticator webroot --webroot-path /usr/local/ispconfig/interface/acme --email " . escapeshellarg ('postmaster@$hostname ' ) . " -d " . escapeshellarg ($ hostname ) . " $ renew_hook " , $ out , $ ret );
2962+ exec ("$ le_client $ certonly $ acme_version --authenticator webroot --webroot-path /usr/local/ispconfig/interface/acme --email " . escapeshellarg ('postmaster@ ' . $ hostname ) . " -d " . escapeshellarg ($ hostname ) . " $ renew_hook " , $ out , $ ret );
29512963 }
29522964 // Else, it is not webserver, so we use standalone
29532965 else {
2954- exec ("$ le_client $ certonly $ acme_version --standalone --email " . escapeshellarg ('postmaster@$hostname ' ) . " -d " . escapeshellarg ($ hostname ) . " $ hook " , $ out , $ ret );
2966+ exec ("$ le_client $ certonly $ acme_version --standalone --email " . escapeshellarg ('postmaster@ ' . $ hostname ) . " -d " . escapeshellarg ($ hostname ) . " $ hook " , $ out , $ ret );
29552967 }
29562968
29572969 if ($ ret == 0 ) {
@@ -2969,7 +2981,11 @@ public function make_ispconfig_ssl_cert() {
29692981 }
29702982
29712983 $ issued_successfully = true ;
2984+ } else {
2985+ swriteln ('Issuing certificate via certbot failed. Please check log files and make sure that your hostname can be verified by letsencrypt ' );
29722986 }
2987+ } else {
2988+ swriteln ('Did not find any valid acme client (acme.sh or certbot) ' );
29732989 }
29742990 }
29752991
@@ -2985,6 +3001,12 @@ public function make_ispconfig_ssl_cert() {
29853001
29863002 // If the LE SSL certs for this hostname exists
29873003 if (!is_dir ($ acme_cert_dir ) || !file_exists ($ check_acme_file ) || !$ issued_successfully ) {
3004+ if (!$ issued_successfully ) {
3005+ swriteln ('Could not issue letsencrypt certificate, falling back to self-signed. ' );
3006+ } else {
3007+ swriteln ('Issuing certificate seems to have succeeded but ' . $ check_acme_file . ' seems to be missing. Falling back to self-signed. ' );
3008+ }
3009+
29883010 // We can still use the old self-signed method
29893011 $ ssl_pw = substr (md5 (mt_rand ()), 0 , 6 );
29903012 exec ("openssl genrsa -des3 -passout pass: $ ssl_pw -out $ ssl_key_file 4096 " );
0 commit comments