handle alternate challenge store func sig

This commit is contained in:
AJ ONeal 2015-12-17 04:44:28 +00:00
parent 9ffdb9b134
commit 54198e0499
2 changed files with 41 additions and 5 deletions

View File

@ -97,8 +97,17 @@ LE.create = function (defaults, handlers, backend) {
// but realistically there only needs to be one handler and one // but realistically there only needs to be one handler and one
// "directory" for this. It's not that big of a deal. // "directory" for this. It's not that big of a deal.
var defaultos = LE.merge(defaults, {}); var defaultos = LE.merge(defaults, {});
var getChallenge = require('./lib/default-handlers').getChallenge;
defaultos.domains = [hostname]; defaultos.domains = [hostname];
require('./lib/default-handlers').getChallenge(defaultos, key, done); if (3 === getChallenge.length) {
getChallenge(defaultos, key, done);
}
else if (4 === getChallenge.length) {
getChallenge(defaultos, hostname, key, done);
}
else {
done(new Error("handlers.getChallenge [1] receives the wrong number of arguments"));
}
}; };
} }
if (!handlers.setChallenge) { if (!handlers.setChallenge) {
@ -216,14 +225,25 @@ LE.create = function (defaults, handlers, backend) {
//args.domains = [req.hostname]; //args.domains = [req.hostname];
//console.log('[LE middleware]:', req.hostname, req.url, req.url.slice(prefix.length)); //console.log('[LE middleware]:', req.hostname, req.url, req.url.slice(prefix.length));
handlers.getChallenge(req.hostname, req.url.slice(prefix.length), function (err, token) { function done(err, token) {
if (err) { if (err) {
res.send("Error: These aren't the tokens you're looking for. Move along."); res.send("Error: These aren't the tokens you're looking for. Move along.");
return; return;
} }
res.send(token); res.send(token);
}); }
if (3 === handlers.getChallenge.length) {
handlers.getChallenge(req.hostname, req.url.slice(prefix.length), done);
}
else if (4 === handlers.getChallenge.length) {
handlers.getChallenge(defaults, req.hostname, req.url.slice(prefix.length), done);
}
else {
console.error("handlers.getChallenge [2] receives the wrong number of arguments");
done(new Error("handlers.getChallenge [2] receives the wrong number of arguments"));
}
}; };
} }
, SNICallback: sniCallback , SNICallback: sniCallback

View File

@ -152,12 +152,28 @@ function getCertificateAsync(account, args, defaults, handlers) {
, setChallenge: function (domain, key, value, done) { , setChallenge: function (domain, key, value, done) {
args.domains = [domain]; args.domains = [domain];
args.webrootPath = args.webrootPath || defaults.webrootPath; args.webrootPath = args.webrootPath || defaults.webrootPath;
handlers.setChallenge(args, key, value, done); if (4 === handlers.setChallenge.length) {
handlers.setChallenge(args, key, value, done);
}
else if (5 === handlers.setChallenge.length) {
handlers.setChallenge(args, domain, key, value, done);
}
else {
done(new Error("handlers.setChallenge receives the wrong number of arguments"));
}
} }
, removeChallenge: function (domain, key, done) { , removeChallenge: function (domain, key, done) {
args.domains = [domain]; args.domains = [domain];
args.webrootPath = args.webrootPath || defaults.webrootPath; args.webrootPath = args.webrootPath || defaults.webrootPath;
handlers.removeChallenge(args, key, done); if (3 === handlers.removeChallenge.length) {
handlers.removeChallenge(args, key, done);
}
else if (4 === handlers.removeChallenge.length) {
handlers.removeChallenge(args, domain, key, done);
}
else {
done(new Error("handlers.removeChallenge receives the wrong number of arguments"));
}
} }
}).then(function (result) { }).then(function (result) {
// TODO write pems={ca,cert,key} to disk // TODO write pems={ca,cert,key} to disk