Added error handling for HTTPS key/cert file loading.
This commit is contained in:
parent
069cb423fd
commit
401b9e4fee
|
|
@ -91,13 +91,23 @@ let webServer = null;
|
||||||
|
|
||||||
//If we're using HTTPS
|
//If we're using HTTPS
|
||||||
if(config.protocol.toLowerCase() == "https"){
|
if(config.protocol.toLowerCase() == "https"){
|
||||||
//Read key/cert files and store contents
|
try{
|
||||||
const httpsOptions = {
|
//Read key/cert files and store contents
|
||||||
key: fs.readFileSync(config.ssl.key),
|
const httpsOptions = {
|
||||||
cert: fs.readFileSync(config.ssl.cert)
|
key: fs.readFileSync(config.ssl.key),
|
||||||
};
|
cert: fs.readFileSync(config.ssl.cert)
|
||||||
|
};
|
||||||
|
|
||||||
webServer = https.createServer(httpsOptions, app);
|
webServer = https.createServer(httpsOptions, app);
|
||||||
|
}catch(err){
|
||||||
|
if(err.path != null && err.path != ""){
|
||||||
|
console.log(`Error opening key/cert file: ${err.path}`);
|
||||||
|
}else{
|
||||||
|
console.log("Unknown error occured while starting HTTPS server! Bailing out!");
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
|
||||||
//Otherwise
|
//Otherwise
|
||||||
}else{
|
}else{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue