@@ -2409,17 +2409,20 @@ public function make_ispconfig_ssl_cert() {
24092409 if (checkdnsrr (idn_to_ascii ($ hostname ), 'A ' )) {
24102410 $ dns_A =dns_get_record ($ hostname , DNS_A ); $ dns_ip =$ dns_A [0 ][ip];
24112411 }
2412+
24122413 // Check if LE SSL folder for the hostname existed
2414+ // Then create standalone LE SSL certs for this server
24132415 $ le_live_dir = '/etc/letsencrypt/live/ ' . $ hostname ;
2414-
2415- // We support certbot so let's create standalone LE SSL certs for this server
24162416 if (!@is_dir ($ le_live_dir ) && ($ svr_ip = $ dns_ip )) {
2417+
24172418 // If it is nginx webserver
24182419 if ($ conf ['nginx ' ]['installed ' ] == true )
24192420 exec ("certbot certonly --authenticator standalone -d $ hostname --pre-hook 'service nginx stop' --post-hook 'service nginx start' " );
2421+
24202422 // If it is apache2 webserver
24212423 elseif ($ conf ['apache ' ]['installed ' ] == true )
24222424 exec ("certbot certonly --authenticator standalone -d $ hostname --pre-hook 'service apache2 stop' --post-hook 'service apache2 start' " );
2425+
24232426 // If it is not webserver
24242427 else
24252428 exec ("certbot certonly --authenticator standalone -d $ hostname " );
@@ -2439,18 +2442,17 @@ public function make_ispconfig_ssl_cert() {
24392442 if (is_dir ($ le_live_dir ) && ($ svr_ip = $ dns_ip )) {
24402443
24412444 // Backup existing ispserver ssl files
2442- if ( is_file ( $ ssl_bak_file )) exec ( " rm $ ssl_bak_file " );
2443- if (is_file ($ ssl_crt_file )) exec ( " mv $ ssl_crt_file- \$ ( date +'%y%m%d%H%M%S). bak" );
2444- if (is_file ( $ ssl_key_file )) exec ( " mv $ ssl_key_file- \$ ( date +'%y%m%d%H%M%S). bak" );
2445- if (is_file ( $ ssl_pem_file )) exec ( " mv $ ssl_pem_file- \$ ( date +'%y%m%d%H%M%S). bak" );
2445+ $ date = new DateTime ( );
2446+ if (file_exists ($ ssl_crt_file )) rename ( $ ssl_crt_file , $ ssl_crt_file . ' - ' . $ date-> format ( ' YmdHis ' ) . ' . bak' );
2447+ if (file_exists ( $ ssl_crt_file )) rename ( $ ssl_key_file , $ ssl_key_file . ' - ' . $ date-> format ( ' YmdHis ' ) . ' . bak' );
2448+ if (file_exists ( $ ssl_crt_file )) rename ( $ ssl_pem_file , $ ssl_pem_file . ' - ' . $ date-> format ( ' YmdHis ' ) . ' . bak' );
24462449
24472450 // Create symlink to LE fullchain and key for ISPConfig
2448- exec ( " ln -sf $ le_live_dir/fullchain.pem $ ssl_crt_file" );
2449- exec ( " ln -sf $ le_live_dir/privkey.pem $ ssl_key_file" );
2451+ symlink ( $ le_live_dir. ' /fullchain.pem ' , $ ssl_crt_file );
2452+ symlink ( $ le_live_dir. ' /privkey.pem ' , $ ssl_key_file );
24502453
24512454 // Build ispserver.pem file and chmod it
2452- exec ("cat $ ssl_key_file $ ssl_crt_file > $ ssl_pem_file " );
2453- exec ("chmod 600 $ ssl_pem_file " );
2455+ exec ("cat $ ssl_key_file $ ssl_crt_file > $ ssl_pem_file; chmod 600 $ ssl_pem_file " );
24542456 }
24552457
24562458 if (!@is_dir ($ le_live_dir ) && ($ svr_ip != $ dns_ip )) {
0 commit comments