From 6e91468fb95fffc8c987e5df8885167aa0d675dd Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 23 Dec 2018 10:47:27 -0700 Subject: [PATCH] v2.6.5: support node < 10.14.0 again --- index.js | 24 +++++++++++++++++------- package.json | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index abab3fd..24026c2 100644 --- a/index.js +++ b/index.js @@ -51,7 +51,7 @@ module.exports.create = function (opts) { ); httpType = 'http'; - return { server: server, listen: function () { return new Promise(function (resolve, reject) { + return { server: server, listen: function () { return new PromiseA(function (resolve, reject) { args[0] = p; args.push(function () { if (!greenlock.servername) { @@ -135,11 +135,16 @@ module.exports.create = function (opts) { // ignore the case that check doesn't have all the right args here // to get the same certs that it just got (eventually the right ones will come in) if (!certs) { return; } - console.info("Using '%s' as default certificate", domain); - server.setSecureContext({ - key: Buffer.from(certs.privkey, 'ascii') - , cert: Buffer.from(certs.cert + '\r\n' + certs.chain, 'ascii') - }); + try { + server.setSecureContext({ + key: Buffer.from(certs.privkey, 'ascii') + , cert: Buffer.from(certs.cert + '\r\n' + certs.chain, 'ascii') + }); + console.info("Using '%s' as default certificate", domain); + } catch(e) { + console.warn("node " + process.version + " is out of date and some (nice, but non-critical) features are unavaliable."); + console.warn("Please update to node v10.13+ if possible."); + } server._hasDefaultSecureContext = true; }).catch(function (/*e*/) { // this may be that the test.example.com was requested, but it's listed @@ -210,7 +215,12 @@ module.exports.create = function (opts) { server.then = obj1.listen().then(function (tlsOptions) { if (tlsOptions) { - server.setSecureContext(tlsOptions); + try { + server.setSecureContext(tlsOptions); + } catch(e) { + console.warn("node " + process.version + " is out of date and some (nice, but non-critical) features are unavaliable."); + console.warn("Please update to node v10.13+ if possible."); + } server._hasDefaultSecureContext = true; } return obj2.listen().then(function () { diff --git a/package.json b/package.json index c198e52..2e378fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "greenlock-express", - "version": "2.6.4", + "version": "2.6.5", "description": "Free SSL and managed or automatic HTTPS for node.js with Express, Koa, Connect, Hapi, and all other middleware systems.", "main": "index.js", "homepage": "https://git.coolaj86.com/coolaj86/greenlock-express.js",