@@ -137,6 +137,7 @@ public function get_certbot_command($domains) {
137137 return false ;
138138 }
139139
140+ $ primary_domain = $ domains [0 ];
140141 $ matches = array ();
141142 $ ret = null ;
142143 $ val = 0 ;
@@ -151,18 +152,22 @@ public function get_certbot_command($domains) {
151152 $ acme_version = 'https://acme-v01.api.letsencrypt.org/directory ' ;
152153 }
153154 if (version_compare ($ letsencrypt_version , '0.30 ' , '>= ' )) {
154- $ app ->log ("LE version is " . $ letsencrypt_version . ", so using certificates command " , LOGLEVEL_DEBUG );
155+ $ app ->log ("LE version is " . $ letsencrypt_version . ", so using certificates command and --cert-name instead of --expand " , LOGLEVEL_DEBUG );
155156 $ this ->certbot_use_certcommand = true ;
156157 $ webroot_map = array ();
157158 for ($ i = 0 ; $ i < count ($ domains ); $ i ++) {
158159 $ webroot_map [$ domains [$ i ]] = '/usr/local/ispconfig/interface/acme ' ;
159160 }
160161 $ webroot_args = "--webroot-map " . escapeshellarg (str_replace (array ("\r" , "\n" ), '' , json_encode ($ webroot_map )));
162+ // --cert-name might be working with earlier versions of certbot, but there is no exact version documented
163+ // So for safety reasons we add it to the 0.30 version check as it is documented to work as expected in this version
164+ $ cert_selection_command = "--cert-name $ primary_domain " ;
161165 } else {
162166 $ webroot_args = "$ cmd --webroot-path /usr/local/ispconfig/interface/acme " ;
167+ $ cert_selection_command = "--expand " ;
163168 }
164169
165- $ cmd = $ letsencrypt . " certonly -n --text --agree-tos --expand --authenticator webroot --server $ acme_version --rsa-key-size 4096 --email postmaster@ $ domain $ webroot_args " ;
170+ $ cmd = $ letsencrypt . " certonly -n --text --agree-tos $ cert_selection_command --authenticator webroot --server $ acme_version --rsa-key-size 4096 --email webmaster@ $ primary_domain $ webroot_args " ;
166171
167172 return $ cmd ;
168173 }
0 commit comments