From d5d14bd9685069cf7c39c6d4a1eb0bbd316786da Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 5 Apr 2019 18:24:34 -0600 Subject: [PATCH] v2.7.9: further simplify storage module requirements --- index.js | 6 ++---- lib/core.js | 27 ++++++++++++--------------- package-lock.json | 8 ++++---- package.json | 2 +- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/index.js b/index.js index b8c117f..c8d0acf 100644 --- a/index.js +++ b/index.js @@ -28,14 +28,12 @@ function promisifyAllStore(obj) { var p; if (1 === obj[key].length) { // wrap just in case it's synchronous (or improperly throws) - p = function (opts) { - return PromiseA.resolve(obj[key](opts)); - }; + p = function (opts) { return PromiseA.resolve().then(function () { obj[key](opts); }) }; } else { p = util.promisify(obj[key]); } // internal backwards compat - obj[key + 'Async'] = util.promisify(obj[key]); + obj[key + 'Async'] = p; }); obj.__promisified = true; return obj; diff --git a/lib/core.js b/lib/core.js index 69f073d..33ed720 100644 --- a/lib/core.js +++ b/lib/core.js @@ -494,25 +494,22 @@ module.exports.create = function (gl) { // returns pems return gl.store.certificates.checkAsync(args).then(function (cert) { - if (cert) { - cert = utils.attachCertInfo(cert); - if (utils.certHasDomain(cert, args.domain)) { - log(args.debug, 'checkAsync found existing certificates'); + if (!cert) { log(args.debug, 'checkAsync failed to find certificates'); return null; } - if (cert.privkey) { + cert = utils.attachCertInfo(cert); + if (utils.certHasDomain(cert, args.domain)) { + log(args.debug, 'checkAsync found existing certificates'); + + if (cert.privkey) { + return cert; + } else { + return gl.store.certificates.checkKeypairAsync(args).then(function (keypair) { + cert.privkey = RSA.exportPrivatePem(keypair).privateKeyPem; return cert; - } else { - return gl.store.certificates.checkKeypairAsync(args).then(function (keypair) { - cert.privkey = RSA.exportPrivatePem(keypair).privateKeyPem; - return cert; - }); - } + }); } - log(args.debug, 'checkAsync found mismatched / incomplete certificates'); } - - log(args.debug, 'checkAsync failed to find certificates'); - return null; + log(args.debug, 'checkAsync found mismatched / incomplete certificates'); }); } // Certificates diff --git a/package-lock.json b/package-lock.json index 6383f28..bbecff5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "greenlock", - "version": "2.7.7", + "version": "2.7.9", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -64,9 +64,9 @@ "integrity": "sha512-aEUP+DB5mfHi4kHY37nJdtVr+DIF5vxiXKdiZBPOLNgF7pK3iD0wJU6fiwDRtZRz2KOahX+VBxlgTN2r24nKhw==" }, "le-store-certbot": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/le-store-certbot/-/le-store-certbot-2.2.1.tgz", - "integrity": "sha512-BhljZjTULhbNBAT6RBiv4TeZegFraMxURYEvh3WRUI048zmXf4ZfC8gwbdu5fnD2tTCsS9fbsCOAQyrFBl4jlA==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/le-store-certbot/-/le-store-certbot-2.2.2.tgz", + "integrity": "sha512-KOU8O2KAtUUiNj8SGdj4gg7v6Je2v5E/2IipzVIvs2bBM6+OsbVTFKz7/7PKm4t2dT2IoI93TYpi69lV29fkpQ==", "requires": { "mkdirp": "^0.5.1", "pyconf": "^1.1.5", diff --git a/package.json b/package.json index cb8c43a..e67afcd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "greenlock", - "version": "2.7.9-rc1", + "version": "2.7.9", "description": "Let's Encrypt for node.js on npm", "main": "index.js", "files": [