le.challenge -> le.challenges[challengeType]

This commit is contained in:
AJ ONeal 2016-09-13 18:08:13 -06:00
parent e2435c07bf
commit 853ea09a56
2 changed files with 6 additions and 4 deletions

View File

@ -243,14 +243,15 @@ module.exports.create = function (le) {
var copy = utils.merge({ domains: [domain] }, le);
utils.tplCopy(copy);
le.challenge.set(copy, domain, key, value, done);
// TODO need to save challengeType
le.challenges[args.challengeType].set(copy, domain, key, value, done);
};
certReq.removeChallenge = function (domain, key, done) {
log(args.debug, "setChallenge called for '" + domain + "'");
var copy = utils.merge({ domains: [domain] }, le);
utils.tplCopy(copy);
le.challenge.remove(copy, domain, key, done);
le.challenges[args.challengeType].remove(copy, domain, key, done);
};
log(args.debug, 'calling le.acme.getCertificateAsync', certReq.domains);

View File

@ -12,7 +12,7 @@ function _log(debug) {
}
module.exports.create = function (le) {
if (!le.challenge || !le.challenge.get) {
if (!le.challenges['http-01'] || !le.challenges['http-01'].get) {
throw new Error("middleware requires challenge plugin with get method");
}
var log = le.log || _log;
@ -51,7 +51,8 @@ module.exports.create = function (le) {
copy = utils.tplCopy(copy);
// TODO tpl copy?
le.challenge.get(copy, hostname, token, function (err, secret) {
// TODO need to restore challengeType
le.challenges['http-01'].get(copy, hostname, token, function (err, secret) {
if (err || !token) {
res.statusCode = 404;
res.setHeader('Content-Type', 'application/json; charset=utf-8');