@@ -1169,6 +1169,9 @@ public function configure_postfix($options = '') {
11691169 $ postconf_commands = array_merge ($ postconf_commands , array_filter (explode ("\n" , $ content )));
11701170 }
11711171
1172+ // Remove comment lines, these would give fatal errors when passed to postconf.
1173+ $ postconf_commands = array_filter ($ postconf_commands , function ($ line ) { return preg_match ('/^[^#]/ ' , $ line ); });
1174+
11721175 //* These postconf commands will be executed on installation only
11731176 if ($ this ->is_update == false ) {
11741177 $ postconf_commands = array_merge ($ postconf_commands , array (
@@ -2550,7 +2553,7 @@ public function configure_apps_vhost() {
25502553 }
25512554
25522555 // comment out the listen directive if port is 80 or 443
2553- if ($ conf ['web ' ]['apps_vhost_ip ' ] == 80 or $ conf ['web ' ]['apps_vhost_ip ' ] == 443 ) {
2556+ if ($ conf ['web ' ]['apps_vhost_port ' ] == 80 or $ conf ['web ' ]['apps_vhost_port ' ] == 443 ) {
25542557 $ tpl ->setVar ('vhost_port_listen ' ,'# ' );
25552558 } else {
25562559 $ tpl ->setVar ('vhost_port_listen ' ,'' );
@@ -2718,9 +2721,15 @@ private function curl_request($url, $use_ipv6 = false) {
27182721 return $ response ;
27192722 }
27202723
2721- private function make_acme_vhost ($ server_name , $ server = 'apache ' ) {
2724+ public function make_acme_vhost ($ server = 'apache ' ) {
27222725 global $ conf ;
27232726
2727+ if ($ conf ['hostname ' ] !== 'localhost ' && $ conf ['hostname ' ] !== '' ) {
2728+ $ server_name = $ conf ['hostname ' ];
2729+ } else {
2730+ $ server_name = exec ('hostname -f ' );
2731+ }
2732+
27242733 $ use_template = 'apache_acme.conf.master ' ;
27252734 $ use_symlink = '999-acme.conf ' ;
27262735 $ use_name = 'acme.conf ' ;
@@ -2756,14 +2765,6 @@ private function make_acme_vhost($server_name, $server = 'apache') {
27562765 if (!@is_link ($ vhost_conf_enabled_dir .'' . $ use_symlink )) {
27572766 symlink ($ vhost_conf_dir .'/ ' . $ use_name , $ vhost_conf_enabled_dir .'/ ' . $ use_symlink );
27582767 }
2759-
2760- if ($ conf [$ server ]['installed ' ] == true && $ conf [$ server ]['init_script ' ] != '' ) {
2761- if ($ this ->is_update ) {
2762- system ($ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'force-reload ' ).' &> /dev/null || ' . $ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'restart ' ).' &> /dev/null ' );
2763- } else {
2764- system ($ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'restart ' ).' &> /dev/null ' );
2765- }
2766- }
27672768 }
27682769
27692770 public function make_ispconfig_ssl_cert () {
@@ -2834,12 +2835,18 @@ public function make_ispconfig_ssl_cert() {
28342835 }
28352836
28362837 swriteln ('Using certificate path ' . $ acme_cert_dir );
2838+ $ ip_address_match = false ;
28372839 if (!(($ svr_ip4 && in_array ($ svr_ip4 , $ dns_ips )) || ($ svr_ip6 && in_array ($ svr_ip6 , $ dns_ips )))) {
28382840 swriteln ('Server \'s public ip(s) ( ' . $ svr_ip4 . ($ svr_ip6 ? ', ' . $ svr_ip6 : '' ) . ') not found in A/AAAA records for ' . $ hostname . ': ' . implode (', ' , $ dns_ips ));
2841+ if (strtolower ($ inst ->simple_query ('Ignore DNS check and continue to request certificate? ' , array ('y ' , 'n ' ) , 'n ' ,'ignore_hostname_dns ' )) == 'y ' ) {
2842+ $ ip_address_match = true ;
2843+ }
2844+ } else {
2845+ $ ip_address_match = true ;
28392846 }
28402847
28412848
2842- 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 ))) ) {
2849+ 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 ) {
28432850
28442851 // This script is needed earlier to check and open http port 80 or standalone might fail
28452852 // Make executable and temporary symlink latest letsencrypt pre, post and renew hook script before install
@@ -2889,15 +2896,22 @@ public function make_ispconfig_ssl_cert() {
28892896 // first of all create the acme vhosts if not existing
28902897 if ($ conf ['nginx ' ]['installed ' ] == true ) {
28912898 swriteln ('Using nginx for certificate validation ' );
2892- $ this -> make_acme_vhost ( $ hostname , 'nginx ' ) ;
2899+ $ server = 'nginx ' ;
28932900 } elseif ($ conf ['apache ' ]['installed ' ] == true ) {
28942901 swriteln ('Using apache for certificate validation ' );
28952902 if ($ this ->is_update == false && @is_link ($ vhost_conf_enabled_dir .'/000-ispconfig.conf ' )) {
28962903 $ restore_conf_symlink = true ;
28972904 unlink ($ vhost_conf_enabled_dir .'/000-ispconfig.conf ' );
28982905 }
2906+ $ server = 'apache ' ;
2907+ }
28992908
2900- $ this ->make_acme_vhost ($ hostname , 'apache ' );
2909+ if ($ conf [$ server ]['installed ' ] == true && $ conf [$ server ]['init_script ' ] != '' ) {
2910+ if ($ this ->is_update ) {
2911+ system ($ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'force-reload ' ).' &> /dev/null || ' . $ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'restart ' ).' &> /dev/null ' );
2912+ } else {
2913+ system ($ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'restart ' ).' &> /dev/null ' );
2914+ }
29012915 }
29022916
29032917 $ issued_successfully = false ;
@@ -2930,6 +2944,8 @@ public function make_ispconfig_ssl_cert() {
29302944 rename ($ ssl_pem_file , $ ssl_pem_file . '- ' . $ date ->format ('YmdHis ' ) . '.bak ' );
29312945 }
29322946
2947+ $ check_acme_file = $ ssl_crt_file ;
2948+
29332949 // Define LE certs name and path, then install them
29342950 //$acme_cert = "--cert-file $acme_cert_dir/cert.pem";
29352951 $ acme_key = "--key-file " . escapeshellarg ($ ssl_key_file );
@@ -2994,9 +3010,11 @@ public function make_ispconfig_ssl_cert() {
29943010 symlink ($ vhost_conf_dir .'/ispconfig.conf ' , $ vhost_conf_enabled_dir .'/000-ispconfig.conf ' );
29953011 }
29963012 }
2997- } elseif (($ svr_ip4 && in_array ($ svr_ip4 , $ dns_ips )) || ($ svr_ip6 && in_array ($ svr_ip6 , $ dns_ips ))) {
2998- // the directory already exists so we have to assume that it was created previously
2999- $ issued_successfully = true ;
3013+ } else {
3014+ if ($ ip_address_match ) {
3015+ // the directory already exists so we have to assume that it was created previously
3016+ $ issued_successfully = true ;
3017+ }
30003018 }
30013019
30023020 // If the LE SSL certs for this hostname exists
0 commit comments