@@ -2821,24 +2821,28 @@ public function make_ispconfig_ssl_cert() {
28212821 $ date = new DateTime ();
28222822
28232823 // Request for certs if no LE SSL folder for server fqdn exist
2824- $ le_live_dir = '/usr/local/ispconfig/server/scripts/ ' . $ hostname ;
2825- if (!@is_dir ($ le_live_dir )) {
2826- $ le_live_dir = '/root/.acme.sh/ ' . $ hostname ;
2827- if (!@is_dir ($ le_live_dir )) {
2828- $ le_live_dir = '/etc/letsencrypt/live/ ' . $ hostname ;
2824+
2825+ $ acme_cert_dir = '/usr/local/ispconfig/server/scripts/ ' . $ hostname ;
2826+ $ check_acme_file = $ acme_cert_dir . '/ ' . $ hostname . '.cer ' ;
2827+ if (!@is_dir ($ acme_cert_dir )) {
2828+ $ acme_cert_dir = '/root/.acme.sh/ ' . $ hostname ;
2829+ $ check_acme_file = $ acme_cert_dir . '/ ' . $ hostname . '.cer ' ;
2830+ if (!@is_dir ($ acme_cert_dir )) {
2831+ $ acme_cert_dir = '/etc/letsencrypt/live/ ' . $ hostname ;
2832+ $ check_acme_file = $ acme_cert_dir . '/cert.pem ' ;
28292833 }
28302834 }
2831- if (!@is_dir ($ le_live_dir ) && (($ svr_ip4 && in_array ($ svr_ip4 , $ dns_ips )) || ($ svr_ip6 && in_array ($ svr_ip6 , $ dns_ips )))) {
2835+ if (( !@is_dir ($ acme_cert_dir ) || !@ file_exists ( $ check_acme_file ) ) && (($ svr_ip4 && in_array ($ svr_ip4 , $ dns_ips )) || ($ svr_ip6 && in_array ($ svr_ip6 , $ dns_ips )))) {
28322836
28332837 // This script is needed earlier to check and open http port 80 or standalone might fail
28342838 // Make executable and temporary symlink latest letsencrypt pre, post and renew hook script before install
2835- if (file_exists (dirname (getcwd ()) . '/server/scripts/letsencrypt_pre_hook.sh ' )) {
2839+ if (file_exists (dirname (getcwd ()) . '/server/scripts/letsencrypt_pre_hook.sh ' ) && ! file_exists ( ' /usr/local/bin/letsencrypt_pre_hook.sh ' ) ) {
28362840 symlink (dirname (getcwd ()) . '/server/scripts/letsencrypt_pre_hook.sh ' , '/usr/local/bin/letsencrypt_pre_hook.sh ' );
28372841 }
2838- if (file_exists (dirname (getcwd ()) . '/server/scripts/letsencrypt_post_hook.sh ' )) {
2842+ if (file_exists (dirname (getcwd ()) . '/server/scripts/letsencrypt_post_hook.sh ' ) && ! file_exists ( ' /usr/local/bin/letsencrypt_post_hook.sh ' ) ) {
28392843 symlink (dirname (getcwd ()) . '/server/scripts/letsencrypt_post_hook.sh ' , '/usr/local/bin/letsencrypt_post_hook.sh ' );
28402844 }
2841- if (file_exists (dirname (getcwd ()) . '/server/scripts/letsencrypt_renew_hook.sh ' )) {
2845+ if (file_exists (dirname (getcwd ()) . '/server/scripts/letsencrypt_renew_hook.sh ' ) && ! file_exists ( ' /usr/local/bin/letsencrypt_renew_hook.sh ' ) ) {
28422846 symlink (dirname (getcwd ()) . '/server/scripts/letsencrypt_renew_hook.sh ' , '/usr/local/bin/letsencrypt_renew_hook.sh ' );
28432847 }
28442848 chown ('/usr/local/bin/letsencrypt_pre_hook.sh ' , 'root ' );
@@ -2915,7 +2919,7 @@ public function make_ispconfig_ssl_cert() {
29152919 }
29162920
29172921 // Define LE certs name and path, then install them
2918- //$acme_cert = "--cert-file $le_live_dir /cert.pem";
2922+ //$acme_cert = "--cert-file $acme_cert_dir /cert.pem";
29192923 $ acme_key = "--key-file " . escapeshellarg ($ ssl_key_file );
29202924 $ acme_chain = "--fullchain-file " . escapeshellarg ($ ssl_crt_file );
29212925 exec ("$ acme --install-cert -d $ hostname $ acme_key $ acme_chain " );
@@ -2976,7 +2980,7 @@ public function make_ispconfig_ssl_cert() {
29762980 }
29772981
29782982 // If the LE SSL certs for this hostname exists
2979- if (!is_dir ($ le_live_dir ) || !$ issued_successfully ) {
2983+ if (!is_dir ($ acme_cert_dir ) || ! file_exists ( $ check_acme_file ) || !$ issued_successfully ) {
29802984 // We can still use the old self-signed method
29812985 $ ssl_pw = substr (md5 (mt_rand ()), 0 , 6 );
29822986 exec ("openssl genrsa -des3 -passout pass: $ ssl_pw -out $ ssl_key_file 4096 " );
0 commit comments