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

View File

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

View File

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