fix #18 letsencrypt-express

This commit is contained in:
AJ ONeal 2016-02-10 15:41:15 -05:00
parent 02ed27a4bb
commit 1c00c8c901
3 changed files with 23 additions and 10 deletions

View File

@ -176,17 +176,18 @@ LE.create = function (defaults, handlers, backend) {
return; return;
} }
return le.validate(args.domains, function (err) { le.validate(args.domains, function (err) {
if (err) { if (err) {
cb(err); cb(err);
return; return;
} }
if (args.debug) { if (defaults.debug || args.debug) {
console.log("[NLE]: begin registration"); console.log("[NLE]: begin registration");
} }
return backend.registerAsync(copy).then(function (pems) { return backend.registerAsync(copy).then(function (pems) {
if (args.debug) { if (defaults.debug || args.debug) {
console.log("[NLE]: end registration"); console.log("[NLE]: end registration");
} }
cb(null, pems); cb(null, pems);
@ -234,6 +235,7 @@ LE.create = function (defaults, handlers, backend) {
backend.getConfigAsync(args).then(function (pyobj) { backend.getConfigAsync(args).then(function (pyobj) {
cb(null, le.pyToJson(pyobj)); cb(null, le.pyToJson(pyobj));
}, function (err) { }, function (err) {
console.error("[letsencrypt/index.js] getConfig");
console.error(err.stack); console.error(err.stack);
return cb(null, []); return cb(null, []);
}); });
@ -248,6 +250,7 @@ LE.create = function (defaults, handlers, backend) {
if ('ENOENT' === err.code) { if ('ENOENT' === err.code) {
cb(null, []); cb(null, []);
} else { } else {
console.error("[letsencrypt/index.js] getConfigs");
console.error(err.stack); console.error(err.stack);
cb(err); 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) { if (err) {
cb(err); cb(err);
return; return;
@ -304,9 +307,10 @@ LE.create = function (defaults, handlers, backend) {
} }
// still couldn't read the certs after success... that's weird // 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(err, null);
}); });
}, cb); });
}); });
} }
}; };

View File

@ -110,6 +110,7 @@ module.exports.fetchFromDisk = function (args) {
}; };
}, function (err) { }, function (err) {
if (args.debug) { if (args.debug) {
console.error("[letsencrypt/lib/common.js] fetchFromDisk");
console.error(err.stack); console.error(err.stack);
} }
return null; return null;

View File

@ -176,8 +176,7 @@ function writeCertificateAsync(args, defaults, handlers) {
|| path.join(liveDir, 'privkey.pem'); || path.join(liveDir, 'privkey.pem');
if (args.debug) { if (args.debug) {
console.log('################ privkeyPath ################'); console.log('[LE] privkeyPath', privkeyPath);
console.log(privkeyPath);
} }
var archiveDir = args.archiveDir || path.join(args.configDir, 'archive', args.domains[0]); var archiveDir = args.archiveDir || path.join(args.configDir, 'archive', args.domains[0]);
@ -236,14 +235,15 @@ function getCertificateAsync(args, defaults, handlers) {
if (args.domainKeyPath) { if (args.domainKeyPath) {
// TODO use existing pre-generated key if avaibale // 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); promise = leCrypto.generateRsaKeypairAsync(args.rsaKeySize, 65537);
} else { } else {
promise = leCrypto.generateRsaKeypairAsync(args.rsaKeySize, 65537); promise = leCrypto.generateRsaKeypairAsync(args.rsaKeySize, 65537);
} }
promise.then(function (domainKey) { return promise.then(function (domainKey) {
if (args.debug) { if (args.debug) {
console.log("get certificate"); console.log("[letsencrypt/lib/core.js] get certificate");
} }
args.domainPrivateKeyPem = args.domainPrivateKeyPem || domainKey.privateKeyPem; args.domainPrivateKeyPem = args.domainPrivateKeyPem || domainKey.privateKeyPem;
@ -375,6 +375,9 @@ function getOrCreateAcmeAccount(args, defaults, handlers) {
return; return;
} }
*/ */
if (args.debug) {
console.log('[LE] created account');
}
return account; return account;
}); });
/* /*
@ -414,7 +417,6 @@ module.exports.create = function (defaults, handlers) {
copy.accountsDir = copy.accountsDir || path.join(copy.configDir, 'accounts', acmeHostpath); copy.accountsDir = copy.accountsDir || path.join(copy.configDir, 'accounts', acmeHostpath);
return getOrCreateAcmeAccount(copy, defaults, handlers).then(function (account) { return getOrCreateAcmeAccount(copy, defaults, handlers).then(function (account) {
//console.log("account", account);
copy.account = account; copy.account = account;
return getOrCreateRenewal(copy).then(function (pyobj) { return getOrCreateRenewal(copy).then(function (pyobj) {
@ -422,6 +424,12 @@ module.exports.create = function (defaults, handlers) {
copy.pyobj = pyobj; copy.pyobj = pyobj;
return getOrCreateDomainCertificate(copy, defaults, handlers); 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) { , fetchAsync: function (args) {