@@ -2721,9 +2721,15 @@ private function curl_request($url, $use_ipv6 = false) {
27212721 return $ response ;
27222722 }
27232723
2724- private function make_acme_vhost ($ server_name , $ server = 'apache ' , $ restart = true ) {
2724+ public function make_acme_vhost ($ server = 'apache ' ) {
27252725 global $ conf ;
27262726
2727+ if ($ conf ['hostname ' ] !== 'localhost ' && $ conf ['hostname ' ] !== '' ) {
2728+ $ server_name = $ conf ['hostname ' ];
2729+ } else {
2730+ $ server_name = exec ('hostname -f ' );
2731+ }
2732+
27272733 $ use_template = 'apache_acme.conf.master ' ;
27282734 $ use_symlink = '999-acme.conf ' ;
27292735 $ use_name = 'acme.conf ' ;
@@ -2759,15 +2765,6 @@ private function make_acme_vhost($server_name, $server = 'apache', $restart = tr
27592765 if (!@is_link ($ vhost_conf_enabled_dir .'' . $ use_symlink )) {
27602766 symlink ($ vhost_conf_dir .'/ ' . $ use_name , $ vhost_conf_enabled_dir .'/ ' . $ use_symlink );
27612767 }
2762- if ($ restart === true ) {
2763- if ($ conf [$ server ]['installed ' ] == true && $ conf [$ server ]['init_script ' ] != '' ) {
2764- if ($ this ->is_update ) {
2765- system ($ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'force-reload ' ).' &> /dev/null || ' . $ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'restart ' ).' &> /dev/null ' );
2766- } else {
2767- system ($ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'restart ' ).' &> /dev/null ' );
2768- }
2769- }
2770- }
27712768 }
27722769
27732770 public function make_ispconfig_ssl_cert () {
@@ -2838,12 +2835,18 @@ public function make_ispconfig_ssl_cert() {
28382835 }
28392836
28402837 swriteln ('Using certificate path ' . $ acme_cert_dir );
2838+ $ ip_address_match = false ;
28412839 if (!(($ svr_ip4 && in_array ($ svr_ip4 , $ dns_ips )) || ($ svr_ip6 && in_array ($ svr_ip6 , $ dns_ips )))) {
28422840 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 ;
28432846 }
28442847
28452848
2846- 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 ) {
28472850
28482851 // This script is needed earlier to check and open http port 80 or standalone might fail
28492852 // Make executable and temporary symlink latest letsencrypt pre, post and renew hook script before install
@@ -2893,15 +2896,22 @@ public function make_ispconfig_ssl_cert() {
28932896 // first of all create the acme vhosts if not existing
28942897 if ($ conf ['nginx ' ]['installed ' ] == true ) {
28952898 swriteln ('Using nginx for certificate validation ' );
2896- $ this -> make_acme_vhost ( $ hostname , 'nginx ' ) ;
2899+ $ server = 'nginx ' ;
28972900 } elseif ($ conf ['apache ' ]['installed ' ] == true ) {
28982901 swriteln ('Using apache for certificate validation ' );
28992902 if ($ this ->is_update == false && @is_link ($ vhost_conf_enabled_dir .'/000-ispconfig.conf ' )) {
29002903 $ restore_conf_symlink = true ;
29012904 unlink ($ vhost_conf_enabled_dir .'/000-ispconfig.conf ' );
29022905 }
2906+ $ server = 'apache ' ;
2907+ }
29032908
2904- $ 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+ }
29052915 }
29062916
29072917 $ issued_successfully = false ;
@@ -2934,6 +2944,8 @@ public function make_ispconfig_ssl_cert() {
29342944 rename ($ ssl_pem_file , $ ssl_pem_file . '- ' . $ date ->format ('YmdHis ' ) . '.bak ' );
29352945 }
29362946
2947+ $ check_acme_file = $ ssl_crt_file ;
2948+
29372949 // Define LE certs name and path, then install them
29382950 //$acme_cert = "--cert-file $acme_cert_dir/cert.pem";
29392951 $ acme_key = "--key-file " . escapeshellarg ($ ssl_key_file );
@@ -2999,10 +3011,7 @@ public function make_ispconfig_ssl_cert() {
29993011 }
30003012 }
30013013 } else {
3002- if ($ conf ['apache ' ]['installed ' ] == true ) {
3003- $ this ->make_acme_vhost ($ hostname , 'apache ' , false ); // we need this config file but we don't want apache to be restarted at this point
3004- }
3005- if (($ svr_ip4 && in_array ($ svr_ip4 , $ dns_ips )) || ($ svr_ip6 && in_array ($ svr_ip6 , $ dns_ips ))) {
3014+ if ($ ip_address_match ) {
30063015 // the directory already exists so we have to assume that it was created previously
30073016 $ issued_successfully = true ;
30083017 }
0 commit comments