Added error handling for HTTPS key/cert file loading.

This commit is contained in:
rainbow napkin 2025-04-12 06:16:38 -04:00
parent 069cb423fd
commit 401b9e4fee

View file

@ -91,13 +91,23 @@ let webServer = null;
//If we're using HTTPS
if(config.protocol.toLowerCase() == "https"){
//Read key/cert files and store contents
const httpsOptions = {
key: fs.readFileSync(config.ssl.key),
cert: fs.readFileSync(config.ssl.cert)
};
try{
//Read key/cert files and store contents
const httpsOptions = {
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
}else{