update for upcoming v3

This commit is contained in:
AJ ONeal 2019-04-05 19:45:24 -06:00
parent d5d14bd968
commit ca219a00e4
1 changed files with 36 additions and 10 deletions

View File

@ -49,20 +49,46 @@ module.exports.create = function (gl) {
var copy = utils.merge({ domains: [ hostname ] }, gl); var copy = utils.merge({ domains: [ hostname ] }, gl);
copy = utils.tplCopy(copy); 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? function cb(opts) {
// TODO need to restore challengeType var secret = opts.keyAuthorization || opts;
gl.challenges['http-01'].get(copy, hostname, token, function (err, secret) { if (secret && 'string' === typeof secret) {
if (err || !token) { res.setHeader('Content-Type', 'text/plain; charset=utf-8');
res.statusCode = 404; res.end(secret);
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; 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);
});
}; };
}; };
}; };