v2.7.2: use new stuff in acme-v2 and support new le-challenge-dns
This commit is contained in:
parent
03e2513919
commit
fe44523243
18
index.js
18
index.js
|
@ -264,7 +264,7 @@ Greenlock.create = function (gl) {
|
|||
gl.acme = gl.acme.create(gl);
|
||||
}
|
||||
gl.acme = promisifyAllSelf(gl.acme);
|
||||
gl._acmeOpts = gl.acme.getOptions();
|
||||
gl._acmeOpts = gl.acme.options || gl.acme.getOptions();
|
||||
Object.keys(gl._acmeOpts).forEach(function (key) {
|
||||
if (!(key in gl)) {
|
||||
gl[key] = gl._acmeOpts[key];
|
||||
|
@ -309,10 +309,8 @@ Greenlock.create = function (gl) {
|
|||
if (challenger.create) {
|
||||
challenger = gl.challenges[challengeType] = challenger.create(gl);
|
||||
}
|
||||
if (!challenger.getOptionsAsync) {
|
||||
challenger = gl.challenges[challengeType] = promisifyAllSelf(challenger);
|
||||
}
|
||||
gl['_challengeOpts_' + challengeType] = challenger.getOptions();
|
||||
gl['_challengeOpts_' + challengeType] = challenger.options || challenger.getOptions();
|
||||
Object.keys(gl['_challengeOpts_' + challengeType]).forEach(function (key) {
|
||||
if (!(key in gl)) {
|
||||
gl[key] = gl['_challengeOpts_' + challengeType][key];
|
||||
|
@ -320,17 +318,17 @@ Greenlock.create = function (gl) {
|
|||
});
|
||||
|
||||
// TODO wrap these here and now with tplCopy?
|
||||
if (!challenger.set || 5 !== challenger.set.length) {
|
||||
if (!challenger.set || ![5,2,1].includes(challenger.set.length)) {
|
||||
throw new Error("gl.challenges[" + challengeType + "].set receives the wrong number of arguments."
|
||||
+ " You must define setChallenge as function (opts, domain, token, keyAuthorization, cb) { }");
|
||||
+ " You must define setChallenge as function (opts) { return Promise.resolve(); }");
|
||||
}
|
||||
if (challenger.get && 4 !== challenger.get.length) {
|
||||
if (challenger.get && ![4,2,1].includes(challenger.get.length)) {
|
||||
throw new Error("gl.challenges[" + challengeType + "].get receives the wrong number of arguments."
|
||||
+ " You must define getChallenge as function (opts, domain, token, cb) { }");
|
||||
+ " You must define getChallenge as function (opts) { return Promise.resolve(); }");
|
||||
}
|
||||
if (!challenger.remove || 4 !== challenger.remove.length) {
|
||||
if (!challenger.remove || ![4,2,1].includes(challenger.remove.length)) {
|
||||
throw new Error("gl.challenges[" + challengeType + "].remove receives the wrong number of arguments."
|
||||
+ " You must define removeChallenge as function (opts, domain, token, cb) { }");
|
||||
+ " You must define removeChallenge as function (opts) { return Promise.resolve(); }");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
43
lib/core.js
43
lib/core.js
|
@ -339,7 +339,7 @@ module.exports.create = function (gl) {
|
|||
, domainKeypair: domainKeypair
|
||||
, subject: args.subject // TODO handle this in acme-v2
|
||||
, domains: args.domains
|
||||
, challengeType: args.challengeType
|
||||
, challengeTypes: Object.keys(args.challenges)
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -353,21 +353,44 @@ module.exports.create = function (gl) {
|
|||
// Each of these fires individually for each domain,
|
||||
// even though the certificate on the whole may have many domains
|
||||
//
|
||||
certReq.setChallenge = function (domain, key, value, done) {
|
||||
log(args.debug, "setChallenge called for '" + domain + "'");
|
||||
var copy = utils.merge({ domains: [domain] }, args);
|
||||
certReq.setChallenge = function (challenge, done) {
|
||||
log(args.debug, "setChallenge called for '" + challenge.altname + "'");
|
||||
var copy = utils.merge({ domains: [challenge.altname] }, args);
|
||||
copy = utils.merge(copy, gl);
|
||||
utils.tplCopy(copy);
|
||||
copy.challenge = challenge;
|
||||
|
||||
// TODO need to save challengeType
|
||||
gl.challenges[args.challengeType].set(copy, domain, key, value, done);
|
||||
if (1 === gl.challenges[challenge.type].set.length) {
|
||||
gl.challenges[challenge.type].set(copy).then(function (result) {
|
||||
done(null, result);
|
||||
}).catch(done);
|
||||
} else if (2 === gl.challenges[challenge.type].set.length) {
|
||||
gl.challenges[challenge.type].set(copy, done);
|
||||
} else {
|
||||
Object.keys(challenge).forEach(function (key) {
|
||||
done[key] = challenge[key];
|
||||
});
|
||||
gl.challenges[challenge.type].set(copy, challenge.altname, challenge.token, challenge.keyAuthorization, done);
|
||||
}
|
||||
};
|
||||
certReq.removeChallenge = function (domain, key, done) {
|
||||
log(args.debug, "removeChallenge called for '" + domain + "'");
|
||||
var copy = utils.merge({ domains: [domain] }, gl);
|
||||
certReq.removeChallenge = function (challenge, done) {
|
||||
log(args.debug, "removeChallenge called for '" + challenge.altname + "'");
|
||||
var copy = utils.merge({ domains: [challenge.altname] }, gl);
|
||||
utils.tplCopy(copy);
|
||||
copy.challenge = challenge;
|
||||
|
||||
gl.challenges[args.challengeType].remove(copy, domain, key, done);
|
||||
if (1 === gl.challenges[challenge.type].remove.length) {
|
||||
gl.challenges[challenge.type].remove(copy).then(function (result) {
|
||||
done(null, result);
|
||||
}).catch(done);
|
||||
} else if (2 === gl.challenges[challenge.type].remove.length) {
|
||||
gl.challenges[challenge.type].remove(copy, done);
|
||||
} else {
|
||||
Object.keys(challenge).forEach(function (key) {
|
||||
done[key] = challenge[key];
|
||||
});
|
||||
gl.challenges[challenge.type].remove(copy, challenge.altname, challenge.keyAuthorization, done);
|
||||
}
|
||||
};
|
||||
|
||||
log(args.debug, 'calling greenlock.acme.getCertificateAsync', certReq.subject, certReq.domains);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "greenlock",
|
||||
"version": "2.7.1",
|
||||
"version": "2.7.2",
|
||||
"description": "Let's Encrypt for node.js on npm",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
|
|
Loading…
Reference in New Issue