v2.7.3: update dependencies, cleanup, and forwards compat for v3

This commit is contained in:
AJ ONeal 2019-04-02 22:35:54 -06:00
parent fe44523243
commit 0601df80c6
3 changed files with 88 additions and 63 deletions

View File

@ -58,7 +58,7 @@ var u; // undefined
Greenlock._undefined = {
acme: u
, store: u
, challenge: u
//, challenge: u
, challenges: u
, sni: u
, tlsOptions: u
@ -297,15 +297,12 @@ Greenlock.create = function (gl) {
if (gl.challenge) {
console.warn("Deprecated use of gl.challenge. Use gl.challenges['" + Greenlock.challengeType + "'] instead.");
gl.challenges[gl.challengeType] = gl.challenge;
gl.challenge = undefined;
}
Greenlock.challengeTypes.forEach(function (challengeType) {
Object.keys(gl.challenges||{}).forEach(function (challengeType) {
var challenger = gl.challenges[challengeType];
if (!challenger) {
return;
}
if (challenger.create) {
challenger = gl.challenges[challengeType] = challenger.create(gl);
}
@ -384,7 +381,7 @@ Greenlock.create = function (gl) {
gl.approveDomains = null;
}
if (!gl.approveDomains) {
gl.approveDomains = function (lexOpts, certs, cb) {
gl.approveDomains = function (lexOpts, cb) {
var err;
var emsg;
@ -403,7 +400,7 @@ Greenlock.create = function (gl) {
// The acme-v2 package uses pre-flight test challenges to
// verify that each requested domain is hosted by the server
// these checks are sufficient for most use cases
return cb(null, { options: lexOpts, certs: certs });
return cb(null, lexOpts);
}
if (lexOpts.domains.every(function (domain) {
@ -415,7 +412,7 @@ Greenlock.create = function (gl) {
lexOpts.agreeTos = gl.agreeTos;
lexOpts.communityMember = gl.communityMember;
lexOpts.telemetry = gl.telemetry;
return cb(null, { options: lexOpts, certs: certs });
return cb(null, lexOpts);
}
emsg = "tls SNI for '" + lexOpts.domains.join(',') + "' rejected: not in list '" + gl.approvedDomains + "'";
@ -429,30 +426,16 @@ Greenlock.create = function (gl) {
gl.getCertificates = function (domain, certs, cb) {
// certs come from current in-memory cache, not lookup
log(gl.debug, 'gl.getCertificates called for', domain, 'with certs for', certs && certs.altnames || 'NONE');
var opts = { domain: domain, domains: certs && certs.altnames || [ domain ] };
try {
gl.approveDomains(opts, certs, function (_err, results) {
if (_err) {
if (false !== gl.logRejectedDomains) {
console.error("[Error] approveDomains rejected tls sni '" + domain + "'");
console.error("[Error] (see https://git.coolaj86.com/coolaj86/greenlock.js/issues/11)");
if ('E_REJECT_SNI' !== _err.code) {
console.error("[Error] This is the rejection message:");
console.error(_err.message);
}
console.error("");
}
cb(_err);
return;
}
var opts = { domain: domain, domains: certs && certs.altnames || [ domain ], certs: certs };
function cb2(results) {
log(gl.debug, 'gl.approveDomains called with certs for', results.certs && results.certs.altnames || 'NONE', 'and options:');
log(gl.debug, results.options);
var options = results.options || results;
if (results.certs) {
log(gl.debug, 'gl renewing');
return gl.core.certificates.renewAsync(results.options, results.certs).then(
return gl.core.certificates.renewAsync(options, results.certs).then(
function (certs) {
// Workaround for https://github.com/nodejs/node/issues/22389
gl._updateServernames(certs);
@ -465,10 +448,9 @@ Greenlock.create = function (gl) {
cb(e);
}
);
}
else {
} else {
log(gl.debug, 'gl getting from disk or registering new');
return gl.core.certificates.getAsync(results.options).then(
return gl.core.certificates.getAsync(options).then(
function (certs) {
// Workaround for https://github.com/nodejs/node/issues/22389
gl._updateServernames(certs);
@ -482,7 +464,33 @@ Greenlock.create = function (gl) {
}
);
}
});
}
function eb2(_err) {
if (false !== gl.logRejectedDomains) {
console.error("[Error] approveDomains rejected tls sni '" + domain + "'");
console.error("[Error] (see https://git.coolaj86.com/coolaj86/greenlock.js/issues/11)");
if ('E_REJECT_SNI' !== _err.code) {
console.error("[Error] This is the rejection message:");
console.error(_err.message);
}
console.error("");
}
cb(_err);
return;
}
function mb2(_err, results) {
if (_err) { eb2(_err); return; }
cb2(results);
}
try {
if (1 === gl.approveDomains.length) {
gl.approveDomains(opts).then(cb2).catch(eb2);
} else if (2 === gl.approveDomains.length) {
gl.approveDomains(opts, mb2);
} else {
gl.approveDomains(opts, certs, mb2);
}
} catch(e) {
console.error("[ERROR] Something went wrong in approveDomains:");
console.error(e);

16
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "greenlock",
"version": "2.6.9",
"version": "2.7.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -45,6 +45,11 @@
"rasha": "^1.2.4"
}
},
"le-challenge-dns": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/le-challenge-dns/-/le-challenge-dns-2.3.2.tgz",
"integrity": "sha512-3BcmK+gELGpt1heyXRcIOciaUnuN7Yh0aFIBsAof1Lqm9LnQ4CnWRjYXtOsAtXlmhDhtNMs+AytGj6fwYBTr1A=="
},
"le-challenge-fs": {
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/le-challenge-fs/-/le-challenge-fs-2.0.8.tgz",
@ -68,6 +73,15 @@
"safe-replace": "^1.0.3"
}
},
"le-store-fs": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/le-store-fs/-/le-store-fs-1.0.0.tgz",
"integrity": "sha512-UVGFYwZO/kzkeoIbnbuPyUCB2HMWHAoKJQhsIeunyFakIa4J1ozqy136h3uV3GulSN+99ZJfQBT5aoqVZsmfzw==",
"requires": {
"mkdirp": "^0.5.1",
"safe-replace": "^1.1.0"
}
},
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "greenlock",
"version": "2.7.2",
"version": "2.7.3",
"description": "Let's Encrypt for node.js on npm",
"main": "index.js",
"files": [
@ -39,11 +39,14 @@
},
"dependencies": {
"acme": "^1.3.0",
"acme-v2": "^1.6.0",
"cert-info": "^1.5.1",
"keypairs": "^1.2.14",
"le-challenge-dns": "^2.3.2",
"le-challenge-fs": "^2.0.2",
"le-sni-auto": "^2.1.8",
"le-store-certbot": "^2.2.1",
"le-store-fs": "^1.0.0",
"rsa-compat": "^2.0.6"
},
"engines": {