Add frontend TLS/SSL

This commit is contained in:
Aayan L 2017-04-23 01:25:58 -04:00
parent 55aa90ed8b
commit 7839b606a1
2 changed files with 26 additions and 9 deletions

View File

@ -42,6 +42,11 @@
"adminCenter": {
"enabled": false,
"password": "password"
},
"tlsOptions" : {
"enabled": false,
"cert": "",
"key": ""
}
},

View File

@ -1,4 +1,4 @@
var https = require('https');
var fs = require('fs');
var path = require('path');
@ -327,11 +327,23 @@ module.exports = function(logger){
});
try {
if (typeof portalConfig.website.tlsOptions !== 'undefined' && !portalConfig.website.tlsOptions.enabled) {
app.listen(portalConfig.website.port, portalConfig.website.host, function () {
logger.debug(logSystem, 'Server', 'Website started on ' + portalConfig.website.host + ':' + portalConfig.website.port);
});
} else {
var TLSoptions = {
key: fs.readFileSync(portalConfig.website.tlsOptions.key),
cert: fs.readFileSync(portalConfig.website.tlsOptions.cert)
};
https.createServer(TLSoptions, app).listen(portalConfig.website.port, portalConfig.website.host, function() {
logger.debug(logSystem, 'Server', 'TLS Website started on ' + portalConfig.website.host + ':' + portalConfig.website.port);
});
}
}
catch(e){
console.log(e)
logger.error(logSystem, 'Server', 'Could not start website on ' + portalConfig.website.host + ':' + portalConfig.website.port
+ ' - its either in use or you do not have permission');
}