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
|
||||
// "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
|
||||
|
|
|
@ -152,12 +152,28 @@ function getCertificateAsync(account, args, defaults, handlers) {
|
|||
, setChallenge: function (domain, key, value, done) {
|
||||
args.domains = [domain];
|
||||
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) {
|
||||
args.domains = [domain];
|
||||
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) {
|
||||
// TODO write pems={ca,cert,key} to disk
|
||||
|
|
Loading…
Reference in New Issue