handle alternate challenge store func sig
This commit is contained in:
parent
9ffdb9b134
commit
54198e0499
26
index.js
26
index.js
|
@ -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
|
||||||
|
|
|
@ -152,13 +152,29 @@ 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;
|
||||||
|
if (4 === handlers.setChallenge.length) {
|
||||||
handlers.setChallenge(args, key, value, done);
|
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;
|
||||||
|
if (3 === handlers.removeChallenge.length) {
|
||||||
handlers.removeChallenge(args, key, done);
|
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
|
||||||
var liveDir = path.join(args.configDir, 'live', args.domains[0]);
|
var liveDir = path.join(args.configDir, 'live', args.domains[0]);
|
||||||
|
|
Loading…
Reference in New Issue