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
// "directory" for this. It's not that big of a deal.
var defaultos = LE.merge(defaults, {});
var getChallenge = require('./lib/default-handlers').getChallenge;
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) {
@ -216,14 +225,25 @@ LE.create = function (defaults, handlers, backend) {
//args.domains = [req.hostname];
//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) {
res.send("Error: These aren't the tokens you're looking for. Move along.");
return;
}
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

View File

@ -152,13 +152,29 @@ function getCertificateAsync(account, args, defaults, handlers) {
, setChallenge: function (domain, key, value, done) {
args.domains = [domain];
args.webrootPath = args.webrootPath || defaults.webrootPath;
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) {
args.domains = [domain];
args.webrootPath = args.webrootPath || defaults.webrootPath;
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) {
// TODO write pems={ca,cert,key} to disk
var liveDir = path.join(args.configDir, 'live', args.domains[0]);