Skip to content

Commit c5aa2b9

Browse files
committed
add cloudflare renew and make revoke working for both by deleting unnecessary config command
1 parent cff6c4d commit c5aa2b9

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

backend/internal/certificate.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,9 @@ const internalCertificate = {
818818
})
819819
.then((certificate) => {
820820
if (certificate.provider === 'letsencrypt') {
821-
return internalCertificate.renewLetsEncryptSsl(certificate)
821+
let renewMethod = certificate.meta.cloudflare_use ? internalCertificate.renewLetsEncryptCloudFlareSsl : internalCertificate.renewLetsEncryptSsl;
822+
823+
return renewMethod(certificate)
822824
.then(() => {
823825
return internalCertificate.getCertificateInfoFromFile('/etc/letsencrypt/live/npm-' + certificate.id + '/fullchain.pem');
824826
})
@@ -872,6 +874,29 @@ const internalCertificate = {
872874
});
873875
},
874876

877+
/**
878+
* @param {Object} certificate the certificate row
879+
* @returns {Promise}
880+
*/
881+
renewLetsEncryptCloudFlareSsl: (certificate) => {
882+
logger.info('Renewing Let\'sEncrypt certificates for Cert #' + certificate.id + ': ' + certificate.domain_names.join(', '));
883+
884+
let cmd = certbot_command + ' renew --non-interactive ' +
885+
'--cert-name "npm-' + certificate.id + '" ' +
886+
'--disable-hook-validation ' +
887+
(le_staging ? '--staging' : '');
888+
889+
if (debug_mode) {
890+
logger.info('Command:', cmd);
891+
}
892+
893+
return utils.exec(cmd)
894+
.then((result) => {
895+
logger.info(result);
896+
return result;
897+
});
898+
},
899+
875900
/**
876901
* @param {Object} certificate the certificate row
877902
* @param {Boolean} [throw_errors]
@@ -881,7 +906,6 @@ const internalCertificate = {
881906
logger.info('Revoking Let\'sEncrypt certificates for Cert #' + certificate.id + ': ' + certificate.domain_names.join(', '));
882907

883908
let cmd = certbot_command + ' revoke --non-interactive ' +
884-
'--config "' + le_config + '" ' +
885909
'--cert-path "/etc/letsencrypt/live/npm-' + certificate.id + '/fullchain.pem" ' +
886910
'--delete-after-revoke ' +
887911
(le_staging ? '--staging' : '');

0 commit comments

Comments
 (0)