Browse Source

v3.0.12: from http2 back to old https.. :-/

v4 v3.0.12
AJ ONeal 5 years ago
parent
commit
b80537f07b
  1. 6
      examples/cluster/server.js
  2. 6
      examples/http2/server.js
  3. 5
      examples/https/server.js
  4. 2
      examples/spdy/server.js
  5. 8
      main.js
  6. 14
      package-lock.json
  7. 4
      package.json
  8. 23
      servers.js

6
examples/cluster/server.js

@ -14,9 +14,9 @@ require("../../")
// Note: in cluster you CANNOT use in-memory state (see below)
cluster: true,
// This will default to the number of workers being equal to
// n-1 cpus, with a minimum of 2
workers: 4
// This will default to the number of workers being equal to
// n-1 cpus, with a minimum of 2
workers: 4
};
})
.serve(httpsWorker);

6
examples/http2/server.js

@ -12,12 +12,12 @@ var pkg = require("../../package.json");
function httpsWorker(glx) {
//
// HTTP2 is the default httpsServer for node v12+
// (HTTPS/1.1 is used for node <= v11)
// HTTP2 would have been the default httpsServer for node v12+
// However... https://github.com/expressjs/express/issues/3388
//
// Get the raw http2 server:
var http2Server = glx.httpsServer(function(req, res) {
var http2Server = glx.http2Server(function(req, res) {
res.end("Hello, Encrypted World!");
});

5
examples/https/server.js

@ -12,10 +12,9 @@ var pkg = require("../../package.json");
function httpsWorker(glx) {
//
// HTTPS/1.1 is only used for node v11 or lower
// (HTTP2 is used for node v12+)
// HTTPS 1.1 is the default
// (HTTP2 would be the default but... https://github.com/expressjs/express/issues/3388)
//
// Why not just require('https')?
// Get the raw https server:
var httpsServer = glx.httpsServer(null, function(req, res) {

2
examples/spdy/server.js

@ -1,3 +1,3 @@
// SPDY is dead. It was replaced by HTTP2, which is a native node module
//
// Greenlock uses HTTP2 as the default https server in node v12+
// Check out the http2 example just up one folder

8
main.js

@ -8,12 +8,8 @@ var minor = process.versions.node.split(".")[1];
var _hasSetSecureContext = false;
var shouldUpgrade = false;
// TODO can we trust earlier versions as well?
if (major >= 12) {
_hasSetSecureContext = !!require("http2").createSecureServer({}, function() {}).setSecureContext;
} else {
_hasSetSecureContext = !!require("https").createServer({}, function() {}).setSecureContext;
}
// this applies to http2 as well (should exist in both or neither)
_hasSetSecureContext = !!require("https").createServer({}, function() {}).setSecureContext;
// TODO document in issues
if (!_hasSetSecureContext) {

14
package-lock.json

@ -1,6 +1,6 @@
{
"name": "@root/greenlock-express",
"version": "3.0.7",
"version": "3.0.11",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -40,9 +40,9 @@
"integrity": "sha512-OaEub02ufoU038gy6bsNHQOjIn8nUjGiLcaRmJ40IUykneJkIW5fxDqKxQx48cszuNflYldsJLPPXCrGfHs8yQ=="
},
"@root/greenlock": {
"version": "3.0.17",
"resolved": "https://registry.npmjs.org/@root/greenlock/-/greenlock-3.0.17.tgz",
"integrity": "sha512-1XKhcLFEx1WFdn1Bc2rkAE/SL1ZUJYYMZdbnehTrfhCr5Y+9U1gdkNZnR/jInhoUvcicF/PXuZkGVucU50RNUg==",
"version": "3.0.25",
"resolved": "https://registry.npmjs.org/@root/greenlock/-/greenlock-3.0.25.tgz",
"integrity": "sha512-VC8H9MTkbqxlB2LGntmcq5cstkE0TdZLvxm25SO5i7c6abJBVMQafhTD415OXwoGimnmWTn6SZ93Fj73d9QX/w==",
"requires": {
"@root/acme": "^3.0.8",
"@root/csr": "^0.8.1",
@ -77,9 +77,9 @@
"integrity": "sha512-rEUDiUsHtild8GfIjFE9wXtcVxeS+ehCJQBwbQQ3IVfORKHK93CFnRtkr69R75lZFjcmKYVc+AXDB+AeRFOULA=="
},
"@root/request": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/@root/request/-/request-1.4.1.tgz",
"integrity": "sha512-2zSP1v9VhJ3gvm4oph0C4BYCoM3Sj84/Wx4iKdt0IbqbJzfON04EodBq5dsV65UxO/aHZciUBwY2GCZcHqaTYg=="
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/@root/request/-/request-1.4.2.tgz",
"integrity": "sha512-J8FM4+SJuc7WRC+Jz17m+VT2lgI7HtatHhxN1F2ck5aIKUAxJEaR4u/gLBsgT60mVHevKCjKN0O8115UtJjwLw=="
},
"@root/x509": {
"version": "0.7.2",

4
package.json

@ -1,6 +1,6 @@
{
"name": "@root/greenlock-express",
"version": "3.0.11",
"version": "3.0.12",
"description": "Free SSL and managed or automatic HTTPS for node.js with Express, Koa, Connect, Hapi, and all other middleware systems.",
"main": "greenlock-express.js",
"homepage": "https://greenlock.domains",
@ -17,7 +17,7 @@
"example": "examples"
},
"dependencies": {
"@root/greenlock": "^3.0.17",
"@root/greenlock": "^3.0.25",
"redirect-https": "^1.1.5"
},
"trulyOptionalDependencies": {

23
servers.js

@ -31,7 +31,18 @@ Servers.create = function(greenlock) {
var _middlewareApp;
servers.http2Server = function(secureOpts, defaultApp) {
return servers._httpsServer(secureOpts, defaultApp, function(secureOpts, fn) {
secureOpts.allowHTTP1 = true;
return require("http2").createSecureServer(secureOpts, fn);
});
};
servers.httpsServer = function(secureOpts, defaultApp) {
return servers._httpsServer(secureOpts, defaultApp, function(secureOpts, fn) {
return require("https").createServer(secureOpts, fn);
});
};
servers._httpsServer = function(secureOpts, defaultApp, createSecureServer) {
if (defaultApp) {
// TODO guard against being set twice?
_middlewareApp = defaultApp;
@ -143,15 +154,3 @@ function wrapDefaultSniCallback(greenlock, secureOpts) {
secureOpts.SNICallback = sni.create(greenlock, secureOpts);
return secureOpts;
}
function createSecureServer(secureOpts, fn) {
var major = process.versions.node.split(".")[0];
// TODO can we trust earlier versions as well?
if (major >= 12) {
secureOpts.allowHTTP1 = true;
return require("http2").createSecureServer(secureOpts, fn);
} else {
return require("https").createServer(secureOpts, fn);
}
}

Loading…
Cancel
Save