v2.3.10: add utility fn for sanitizing hostnames, reduce buzzwords, drop old deps
This commit is contained in:
parent
20e8d09219
commit
282f748e77
29
index.js
29
index.js
|
@ -481,5 +481,34 @@ Greenlock.create = function (gl) {
|
||||||
gl.middleware = gl.middleware.create(gl);
|
gl.middleware = gl.middleware.create(gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//var SERVERNAME_RE = /^[a-z0-9\.\-_]+$/;
|
||||||
|
var SERVERNAME_G = /[^a-z0-9\.\-_]/;
|
||||||
|
gl.middleware.sanitizeHost = function (req, res, next) {
|
||||||
|
// Get the host:port combo, if it exists
|
||||||
|
var host = (req.headers.host||'').split(':');
|
||||||
|
|
||||||
|
// if not, move along
|
||||||
|
if (!host[0]) { next(req, res); return; }
|
||||||
|
|
||||||
|
// if so, remove non-allowed characters
|
||||||
|
var safehost = host[0].replace(SERVERNAME_G, '');
|
||||||
|
|
||||||
|
// if there were unallowed characters, complain
|
||||||
|
if (!gl.__sni_allow_dangerous_name && safehost.length !== host[0].length) {
|
||||||
|
res.statusCode = 400;
|
||||||
|
res.end("Malformed HTTP Header: 'Host: " + host[0] + "'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make lowercase
|
||||||
|
if (!gl.__sni_preserve_case) {
|
||||||
|
host[0] = host[0].toLowerCase();
|
||||||
|
req.headers.host = host.join(':');
|
||||||
|
}
|
||||||
|
|
||||||
|
// carry on
|
||||||
|
next(req, res);
|
||||||
|
};
|
||||||
|
|
||||||
return gl;
|
return gl;
|
||||||
};
|
};
|
||||||
|
|
22
package.json
22
package.json
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "greenlock",
|
"name": "greenlock",
|
||||||
"version": "2.3.9",
|
"version": "2.3.10",
|
||||||
"description": "Let's Encrypt for node.js on npm",
|
"description": "Let's Encrypt for node.js on npm",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
@ -18,25 +18,12 @@
|
||||||
"letsencrypt",
|
"letsencrypt",
|
||||||
"ACME",
|
"ACME",
|
||||||
"v2",
|
"v2",
|
||||||
"v02",
|
|
||||||
"draft-11",
|
|
||||||
"draft-12",
|
|
||||||
"auto-sni",
|
"auto-sni",
|
||||||
"draft",
|
|
||||||
"11",
|
|
||||||
"12",
|
|
||||||
"Free SSL",
|
"Free SSL",
|
||||||
"Automated HTTPS",
|
"Automated HTTPS",
|
||||||
"tls",
|
"tls",
|
||||||
"https",
|
"https",
|
||||||
"Greenlock",
|
"Greenlock"
|
||||||
"letsencrypt.org",
|
|
||||||
"le",
|
|
||||||
"le.js",
|
|
||||||
"node",
|
|
||||||
"nodejs",
|
|
||||||
"node.js",
|
|
||||||
"client"
|
|
||||||
],
|
],
|
||||||
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
|
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
|
||||||
"license": "(MIT OR Apache-2.0)",
|
"license": "(MIT OR Apache-2.0)",
|
||||||
|
@ -55,13 +42,10 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"acme": "^1.0.6",
|
"acme": "^1.0.6",
|
||||||
"acme-v2": "^1.2.0",
|
"acme-v2": "^1.2.0",
|
||||||
"asn1js": "^1.2.12",
|
"certpem": "^1.1.0",
|
||||||
"certpem": "^1.0.0",
|
|
||||||
"le-challenge-fs": "^2.0.2",
|
"le-challenge-fs": "^2.0.2",
|
||||||
"le-sni-auto": "^2.1.3",
|
"le-sni-auto": "^2.1.3",
|
||||||
"le-store-certbot": "^2.1.7",
|
"le-store-certbot": "^2.1.7",
|
||||||
"node.extend": "^1.1.5",
|
|
||||||
"pkijs": "^1.3.27",
|
|
||||||
"rsa-compat": "^1.5.0"
|
"rsa-compat": "^1.5.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
Loading…
Reference in New Issue