@@ -485,6 +485,8 @@ function update($event_name, $data) {
485485
486486 if ($ this ->action != 'insert ' ) $ this ->action = 'update ' ;
487487
488+ $ update_letsencrypt = false ;
489+
488490 if ($ data ['new ' ]['type ' ] != 'vhost ' && $ data ['new ' ]['type ' ] != 'vhostsubdomain ' && $ data ['new ' ]['type ' ] != 'vhostalias ' && $ data ['new ' ]['parent_domain_id ' ] > 0 ) {
489491
490492 $ old_parent_domain_id = intval ($ data ['old ' ]['parent_domain_id ' ]);
@@ -504,6 +506,7 @@ function update($event_name, $data) {
504506 $ data ['new ' ] = $ tmp ;
505507 $ data ['old ' ] = $ tmp ;
506508 $ this ->action = 'update ' ;
509+ $ update_letsencrypt = true ;
507510 }
508511
509512 // load the server configuration options
@@ -1177,8 +1180,7 @@ function update($event_name, $data) {
11771180 ($ data ['old ' ]['ssl ' ] == 'n ' || $ data ['old ' ]['ssl_letsencrypt ' ] == 'n ' ) // we have new let's encrypt configuration
11781181 || ($ data ['old ' ]['domain ' ] != $ data ['new ' ]['domain ' ]) // we have domain update
11791182 || ($ data ['old ' ]['subdomain ' ] != $ data ['new ' ]['subdomain ' ]) // we have new or update on "auto" subdomain
1180- || ($ data ['new ' ]['type ' ] == 'subdomain ' ) // we have new or update on subdomain
1181- || ($ data ['old ' ]['type ' ] == 'alias ' || $ data ['new ' ]['type ' ] == 'alias ' ) // we have new or update on aliasdomain
1183+ || $ update_letsencrypt == true
11821184 )) {
11831185 // default values
11841186 $ temp_domains = array ();
@@ -1230,13 +1232,14 @@ function update($event_name, $data) {
12301232 $ webroot = $ data ['new ' ]['document_root ' ]."/web " ;
12311233
12321234 //* check if we have already a Let's Encrypt cert
1233- if (!file_exists ($ crt_tmp_file ) && !file_exists ($ key_tmp_file )) {
1235+ //if(!file_exists($crt_tmp_file) && !file_exists($key_tmp_file)) {
1236+ // we must not skip if cert exists, otherwise changed domains (alias or sub) won't make it to the cert
12341237 $ app ->log ("Create Let's Encrypt SSL Cert for: $ domain " , LOGLEVEL_DEBUG );
12351238
12361239 $ success = false ;
12371240 $ letsencrypt = array_shift ( explode ("\n" , shell_exec ('which letsencrypt certbot /root/.local/share/letsencrypt/bin/letsencrypt ' )) );
12381241 if (is_executable ($ letsencrypt )) {
1239- $ success = $ this ->_exec ($ letsencrypt . " certonly --text --agree-tos --authenticator webroot --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --email postmaster@ $ domain --domains $ lddomain --webroot-path /usr/local/ispconfig/interface/acme " );
1242+ $ success = $ this ->_exec ($ letsencrypt . " certonly --text --agree-tos --authenticator webroot --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --email postmaster@ $ domain --domains $ lddomain --webroot-path /usr/local/ispconfig/interface/acme <<< '1' " );
12401243 }
12411244 if (!$ success ) {
12421245 // error issuing cert
@@ -1248,7 +1251,7 @@ function update($event_name, $data) {
12481251 /* Update also the master-DB of the Server-Farm */
12491252 $ app ->dbmaster ->query ("UPDATE web_domain SET `ssl` = ?, `ssl_letsencrypt` = ? WHERE `domain` = ? " , $ data ['new ' ]['ssl ' ], 'n ' , $ data ['new ' ]['domain ' ]);
12501253 }
1251- }
1254+ // }
12521255
12531256 //* check is been correctly created
12541257 if (file_exists ($ crt_tmp_file ) OR file_exists ($ key_tmp_file )) {
@@ -2102,6 +2105,19 @@ function delete($event_name, $data) {
21022105 //exec('fuser -km '.escapeshellarg($data['old']['document_root'].'/'.$log_folder).' 2>/dev/null');
21032106 exec ('umount ' .escapeshellarg ($ data ['old ' ]['document_root ' ].'/ ' .$ log_folder ).' 2>/dev/null ' );
21042107 }
2108+
2109+ // remove letsencrypt if it exists (renew will always fail otherwise)
2110+
2111+ $ domain = $ data ['old ' ]['ssl_domain ' ];
2112+ if (!$ domain ) $ domain = $ data ['old ' ]['domain ' ];
2113+ if (substr ($ domain , 0 , 2 ) === '*. ' ) {
2114+ // wildcard domain not yet supported by letsencrypt!
2115+ $ domain = substr ($ domain , 2 );
2116+ }
2117+ //$crt_tmp_file = "/etc/letsencrypt/live/".$domain."/cert.pem";
2118+ //$key_tmp_file = "/etc/letsencrypt/live/".$domain."/privkey.pem";
2119+ $ le_conf_file = '/etc/letsencrypt/renewal/ ' . $ domain . '.conf ' ;
2120+ @rename ('/etc/letsencrypt/renewal/ ' . $ domain . '.conf ' , '/etc/letsencrypt/renewal/ ' . $ domain . '.conf~backup ' );
21052121 }
21062122
21072123 //* remove mountpoint from fstab
0 commit comments