@@ -861,9 +861,8 @@ const internalCertificate = {
861
861
logger . info ( `Requesting Let'sEncrypt certificates via ${ dnsPlugin . name } for Cert #${ certificate . id } : ${ certificate . domain_names . join ( ', ' ) } ` ) ;
862
862
863
863
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 } ) ;
867
866
868
867
// Whether the plugin has a --<name>-credentials argument
869
868
const hasConfigArg = certificate . meta . dns_provider !== 'route53' ;
@@ -898,17 +897,15 @@ const internalCertificate = {
898
897
mainCmd = mainCmd + ' --dns-duckdns-no-txt-restore' ;
899
898
}
900
899
901
- logger . info ( 'Command:' , ` ${ credentialsCmd } && && ${ mainCmd } ` ) ;
900
+ logger . info ( 'Command:' , mainCmd ) ;
902
901
903
902
try {
904
- await utils . exec ( credentialsCmd ) ;
905
903
const result = await utils . exec ( mainCmd ) ;
906
904
logger . info ( result ) ;
907
905
return result ;
908
906
} 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 , ( ) => { } ) ;
912
909
throw err ;
913
910
}
914
911
} ,
0 commit comments