From 1c00c8c901906d78a8ac7424ac022cc84c09e59c Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 10 Feb 2016 15:41:15 -0500 Subject: [PATCH] fix #18 letsencrypt-express --- index.js | 14 +++++++++----- lib/common.js | 1 + lib/core.js | 18 +++++++++++++----- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 9f55658..87af69a 100644 --- a/index.js +++ b/index.js @@ -176,17 +176,18 @@ LE.create = function (defaults, handlers, backend) { return; } - return le.validate(args.domains, function (err) { + le.validate(args.domains, function (err) { if (err) { cb(err); return; } - if (args.debug) { + if (defaults.debug || args.debug) { console.log("[NLE]: begin registration"); } + return backend.registerAsync(copy).then(function (pems) { - if (args.debug) { + if (defaults.debug || args.debug) { console.log("[NLE]: end registration"); } cb(null, pems); @@ -234,6 +235,7 @@ LE.create = function (defaults, handlers, backend) { backend.getConfigAsync(args).then(function (pyobj) { cb(null, le.pyToJson(pyobj)); }, function (err) { + console.error("[letsencrypt/index.js] getConfig"); console.error(err.stack); return cb(null, []); }); @@ -248,6 +250,7 @@ LE.create = function (defaults, handlers, backend) { if ('ENOENT' === err.code) { cb(null, []); } else { + console.error("[letsencrypt/index.js] getConfigs"); console.error(err.stack); cb(err); } @@ -290,7 +293,7 @@ LE.create = function (defaults, handlers, backend) { } } - return le._registerHelper(args, function (err/*, pems*/) { + le._registerHelper(args, function (err/*, pems*/) { if (err) { cb(err); return; @@ -304,9 +307,10 @@ LE.create = function (defaults, handlers, backend) { } // still couldn't read the certs after success... that's weird + console.error("still couldn't read certs after success... that's weird"); cb(err, null); }); - }, cb); + }); }); } }; diff --git a/lib/common.js b/lib/common.js index 446f9e1..4c67d9f 100644 --- a/lib/common.js +++ b/lib/common.js @@ -110,6 +110,7 @@ module.exports.fetchFromDisk = function (args) { }; }, function (err) { if (args.debug) { + console.error("[letsencrypt/lib/common.js] fetchFromDisk"); console.error(err.stack); } return null; diff --git a/lib/core.js b/lib/core.js index ea61351..a56d921 100644 --- a/lib/core.js +++ b/lib/core.js @@ -176,8 +176,7 @@ function writeCertificateAsync(args, defaults, handlers) { || path.join(liveDir, 'privkey.pem'); if (args.debug) { - console.log('################ privkeyPath ################'); - console.log(privkeyPath); + console.log('[LE] privkeyPath', privkeyPath); } var archiveDir = args.archiveDir || path.join(args.configDir, 'archive', args.domains[0]); @@ -236,14 +235,15 @@ function getCertificateAsync(args, defaults, handlers) { if (args.domainKeyPath) { // TODO use existing pre-generated key if avaibale + console.warn("[LE /lib/core.js] retrieve from domainKeyPath NOT IMPLEMENTED (please file an issue to remind me about this)"); promise = leCrypto.generateRsaKeypairAsync(args.rsaKeySize, 65537); } else { promise = leCrypto.generateRsaKeypairAsync(args.rsaKeySize, 65537); } - promise.then(function (domainKey) { + return promise.then(function (domainKey) { if (args.debug) { - console.log("get certificate"); + console.log("[letsencrypt/lib/core.js] get certificate"); } args.domainPrivateKeyPem = args.domainPrivateKeyPem || domainKey.privateKeyPem; @@ -375,6 +375,9 @@ function getOrCreateAcmeAccount(args, defaults, handlers) { return; } */ + if (args.debug) { + console.log('[LE] created account'); + } return account; }); /* @@ -414,7 +417,6 @@ module.exports.create = function (defaults, handlers) { copy.accountsDir = copy.accountsDir || path.join(copy.configDir, 'accounts', acmeHostpath); return getOrCreateAcmeAccount(copy, defaults, handlers).then(function (account) { - //console.log("account", account); copy.account = account; return getOrCreateRenewal(copy).then(function (pyobj) { @@ -422,6 +424,12 @@ module.exports.create = function (defaults, handlers) { copy.pyobj = pyobj; return getOrCreateDomainCertificate(copy, defaults, handlers); }); + }).then(function (result) { + return result; + }, function (err) { + console.error('[DEBUG le/lib/core.js] registeryAsync err'); + console.error(err && err.stack || err); + return PromiseA.reject(err); }); } , fetchAsync: function (args) {