@@ -861,9 +861,8 @@ const internalCertificate = {
861861 logger . info ( `Requesting Let'sEncrypt certificates via ${ dnsPlugin . name } for Cert #${ certificate . id } : ${ certificate . domain_names . join ( ', ' ) } ` ) ;
862862
863863 const credentialsLocation = '/etc/letsencrypt/credentials/credentials-' + certificate . id ;
864- // Escape single quotes and backslashes
865- const escapedCredentials = certificate . meta . dns_provider_credentials . replaceAll ( '\'' , '\\\'' ) . replaceAll ( '\\' , '\\\\' ) ;
866- const credentialsCmd = 'mkdir -p /etc/letsencrypt/credentials 2> /dev/null; echo \'' + escapedCredentials + '\' > \'' + credentialsLocation + '\' && chmod 600 \'' + credentialsLocation + '\'' ;
864+ fs . mkdirSync ( '/etc/letsencrypt/credentials' , { recursive : true } ) ;
865+ fs . writeFileSync ( credentialsLocation , certificate . meta . dns_provider_credentials , { mode : 0o600 } ) ;
867866
868867 // Whether the plugin has a --<name>-credentials argument
869868 const hasConfigArg = certificate . meta . dns_provider !== 'route53' ;
@@ -898,17 +897,15 @@ const internalCertificate = {
898897 mainCmd = mainCmd + ' --dns-duckdns-no-txt-restore' ;
899898 }
900899
901- logger . info ( 'Command:' , ` ${ credentialsCmd } && && ${ mainCmd } ` ) ;
900+ logger . info ( 'Command:' , mainCmd ) ;
902901
903902 try {
904- await utils . exec ( credentialsCmd ) ;
905903 const result = await utils . exec ( mainCmd ) ;
906904 logger . info ( result ) ;
907905 return result ;
908906 } catch ( err ) {
909- // Don't fail if file does not exist
910- const delete_credentialsCmd = `rm -f '${ credentialsLocation } ' || true` ;
911- await utils . exec ( delete_credentialsCmd ) ;
907+ // Don't fail if file does not exist, so no need for action in the callback
908+ fs . unlink ( credentialsLocation , ( ) => { } ) ;
912909 throw err ;
913910 }
914911 } ,
0 commit comments