update for upcoming v3
This commit is contained in:
parent
d5d14bd968
commit
ca219a00e4
|
@ -49,20 +49,46 @@ module.exports.create = function (gl) {
|
|||
|
||||
var copy = utils.merge({ domains: [ hostname ] }, gl);
|
||||
copy = utils.tplCopy(copy);
|
||||
copy.challenge = {};
|
||||
copy.challenge.type = 'http-01'; // obviously...
|
||||
copy.challenge.identifier = { type: 'dns', value: hostname };
|
||||
copy.challenge.wildcard = false;
|
||||
copy.challenge.token = token;
|
||||
copy.challenge.altname = hostname;
|
||||
|
||||
// TODO tpl copy?
|
||||
// TODO need to restore challengeType
|
||||
gl.challenges['http-01'].get(copy, hostname, token, function (err, secret) {
|
||||
if (err || !token) {
|
||||
function cb(opts) {
|
||||
var secret = opts.keyAuthorization || opts;
|
||||
if (secret && 'string' === typeof secret) {
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
|
||||
res.end(secret);
|
||||
return;
|
||||
}
|
||||
eb(new Error("couldn't retrieve keyAuthorization"));
|
||||
return;
|
||||
}
|
||||
function eb(/*err*/) {
|
||||
res.statusCode = 404;
|
||||
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
||||
res.end('{ "error": { "message": "Error: These aren\'t the tokens you\'re looking for. Move along." } }');
|
||||
return;
|
||||
}
|
||||
function mb(err, result) {
|
||||
if (err) { eb(err); return; }
|
||||
cb(result);
|
||||
}
|
||||
|
||||
var challenger = gl.challenges['http-01'].get;
|
||||
if (1 === challenger.length) {
|
||||
/*global Promise*/
|
||||
return Promise.resolve().then(function () {
|
||||
return gl.challenges['http-01'].get(copy);
|
||||
}).then(cb).catch(eb);
|
||||
} else if (2 === challenger.length) {
|
||||
gl.challenges['http-01'].get(copy, mb);
|
||||
} else {
|
||||
gl.challenges['http-01'].get(copy, hostname, token, mb);
|
||||
}
|
||||
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
|
||||
res.end(secret);
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue