From 59b7fffa6afa969daf3aac1d54d4514406f7d0a7 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 16 Aug 2016 13:02:14 -0400 Subject: [PATCH] better debugging when debug flag is set --- index.js | 16 +++++++++++++++- lib/core.js | 7 ++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index d220ddb..e990636 100644 --- a/index.js +++ b/index.js @@ -192,9 +192,17 @@ LE.create = function (le) { } le.getCertificates = function (domain, certs, cb) { + // certs come from current in-memory cache, not lookup + if (le.debug) { + console.log('le.getCertificates called for', domain, 'with certs for', certs && certs.altnames || 'NONE'); + } var opts = { domain: domain, domains: certs && certs.altnames || [ domain ] }; le.approveDomains(opts, certs, function (_err, results) { + if (le.debug) { + console.log('le.approveDomains called with certs for', results.certs && results.certs.altnames || 'NONE', 'and options:'); + console.log(results.options); + } if (_err) { cb(_err); return; @@ -203,10 +211,16 @@ LE.create = function (le) { var promise; if (results.certs) { + if (le.debug) { + console.log('le renewing'); + } promise = le.core.certificates.renewAsync(results.options, results.certs); } else { - promise = le.core.certificates.registerAsync(results.options); + if (le.debug) { + console.log('le getting from disk or registering new'); + } + promise = le.core.certificates.getAsync(results.options); } return promise.then(function (certs) { cb(null, certs); }, cb); diff --git a/lib/core.js b/lib/core.js index 7c45162..9d45511 100644 --- a/lib/core.js +++ b/lib/core.js @@ -252,8 +252,7 @@ module.exports.create = function (le) { le.challenge.remove(copy, domain, key, done); }; - log(args.debug, 'BEFORE GET CERT'); - log(args.debug, certReq); + log(args.debug, 'calling le.acme.getCertificateAsync', certReq.domains); return le.acme.getCertificateAsync(certReq).then(utils.attachCertInfo); }); @@ -317,6 +316,7 @@ module.exports.create = function (le) { log(args.debug, "Check Renewable At", new Date(renewableAt).toISOString()); if (args.duplicate || Date.now() >= renewableAt) { + log(args.debug, "certificates are renewable"); return true; } @@ -332,9 +332,11 @@ module.exports.create = function (le) { // returns pems return le.store.certificates.checkAsync(copy).then(function (cert) { if (cert) { + log(args.debug, 'checkAsync found existing certificates'); return utils.attachCertInfo(cert); } + log(args.debug, 'checkAsync failed to find certificates'); return null; }); } @@ -346,7 +348,6 @@ module.exports.create = function (le) { return core.certificates.checkAsync(args).then(function (certs) { if (!certs) { // There is no cert available - log(args.debug, "no certificate found"); return core.certificates.registerAsync(args); }