forked from svrjs/svrjs
Log certificate loading errors
This commit is contained in:
parent
c7c381d8c9
commit
d0064ee083
2 changed files with 17 additions and 11 deletions
|
@ -3,7 +3,7 @@
|
||||||
"port": 80,
|
"port": 80,
|
||||||
"pubport": 80,
|
"pubport": 80,
|
||||||
"page404": "404.html",
|
"page404": "404.html",
|
||||||
"timestamp": 1694212357224,
|
"timestamp": 1694334249412,
|
||||||
"blacklist": [],
|
"blacklist": [],
|
||||||
"nonStandardCodes": [],
|
"nonStandardCodes": [],
|
||||||
"enableCompression": true,
|
"enableCompression": true,
|
||||||
|
|
6
svr.js
6
svr.js
|
@ -1265,8 +1265,10 @@ if (!fs.existsSync(__dirname + "/config.json")) {
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var certificateError = null;
|
||||||
// Load SNI
|
// Load SNI
|
||||||
if (secure) {
|
if (secure) {
|
||||||
|
try {
|
||||||
key = fs.readFileSync((configJSON.key[0] != "/" && !configJSON.key.match(/^[A-Z0-9]:\\/)) ? __dirname + "/" + configJSON.key : configJSON.key).toString();
|
key = fs.readFileSync((configJSON.key[0] != "/" && !configJSON.key.match(/^[A-Z0-9]:\\/)) ? __dirname + "/" + configJSON.key : configJSON.key).toString();
|
||||||
cert = fs.readFileSync((configJSON.cert[0] != "/" && !configJSON.cert.match(/^[A-Z0-9]:\\/)) ? __dirname + "/" + configJSON.cert : configJSON.cert).toString();
|
cert = fs.readFileSync((configJSON.cert[0] != "/" && !configJSON.cert.match(/^[A-Z0-9]:\\/)) ? __dirname + "/" + configJSON.cert : configJSON.cert).toString();
|
||||||
var sniNames = Object.keys(sni);
|
var sniNames = Object.keys(sni);
|
||||||
|
@ -1278,6 +1280,9 @@ if (secure) {
|
||||||
key: fs.readFileSync((sni[sniName].key[0] != "/" && !sni[sniName].key.match(/^[A-Z0-9]:\\/)) ? __dirname + "/" + sni[sniName].key : sni[sniName].key).toString()
|
key: fs.readFileSync((sni[sniName].key[0] != "/" && !sni[sniName].key.match(/^[A-Z0-9]:\\/)) ? __dirname + "/" + sni[sniName].key : sni[sniName].key).toString()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} catch(err) {
|
||||||
|
certificateError = err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var logFile = undefined;
|
var logFile = undefined;
|
||||||
|
@ -4865,6 +4870,7 @@ function start(init) {
|
||||||
if (brdIPs.indexOf(listenAddress) > -1) throw new Error("SVR.JS can't listen on broadcast address.");
|
if (brdIPs.indexOf(listenAddress) > -1) throw new Error("SVR.JS can't listen on broadcast address.");
|
||||||
if (netIPs.indexOf(listenAddress) > -1) throw new Error("SVR.JS can't listen on subnet address.");
|
if (netIPs.indexOf(listenAddress) > -1) throw new Error("SVR.JS can't listen on subnet address.");
|
||||||
}
|
}
|
||||||
|
if(certificateError) throw new Error("There was a problem with SSL certificate/private key: " + certificateError.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Information about starting the server
|
// Information about starting the server
|
||||||
|
|
Reference in a new issue