v2.6.5: support node < 10.14.0 again

This commit is contained in:
AJ ONeal 2018-12-23 10:47:27 -07:00
parent 779ab234ac
commit 6e91468fb9
2 changed files with 18 additions and 8 deletions

View File

@ -51,7 +51,7 @@ module.exports.create = function (opts) {
); );
httpType = 'http'; 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[0] = p;
args.push(function () { args.push(function () {
if (!greenlock.servername) { 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 // 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) // to get the same certs that it just got (eventually the right ones will come in)
if (!certs) { return; } if (!certs) { return; }
console.info("Using '%s' as default certificate", domain); try {
server.setSecureContext({ server.setSecureContext({
key: Buffer.from(certs.privkey, 'ascii') key: Buffer.from(certs.privkey, 'ascii')
, cert: Buffer.from(certs.cert + '\r\n' + certs.chain, '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; server._hasDefaultSecureContext = true;
}).catch(function (/*e*/) { }).catch(function (/*e*/) {
// this may be that the test.example.com was requested, but it's listed // 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) { server.then = obj1.listen().then(function (tlsOptions) {
if (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; server._hasDefaultSecureContext = true;
} }
return obj2.listen().then(function () { return obj2.listen().then(function () {

View File

@ -1,6 +1,6 @@
{ {
"name": "greenlock-express", "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.", "description": "Free SSL and managed or automatic HTTPS for node.js with Express, Koa, Connect, Hapi, and all other middleware systems.",
"main": "index.js", "main": "index.js",
"homepage": "https://git.coolaj86.com/coolaj86/greenlock-express.js", "homepage": "https://git.coolaj86.com/coolaj86/greenlock-express.js",