better debugging when debug flag is set

This commit is contained in:
AJ ONeal 2016-08-16 13:02:14 -04:00
parent 7b71e0bd38
commit 59b7fffa6a
2 changed files with 19 additions and 4 deletions

View File

@ -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);

View File

@ -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);
}