Commit 0863ab0e authored by Mike's avatar Mike

add support for ssl (required for Chrome WebRTC); add dep for amqp

parent 5aa9d35f
......@@ -2,6 +2,8 @@
* Module dependencies.
*/
var express = require('express');
var http = require('http');
var https = require('https');
var compress = require('compression');
var session = require('express-session');
var bodyParser = require('body-parser');
......@@ -18,6 +20,7 @@ var expressValidator = require('express-validator');
var sass = require('node-sass-middleware');
var multer = require('multer');
var upload = multer({ dest: path.join(__dirname, 'uploads') });
var fs = require('fs');
var serviceManager = require('./mcu/manager');
serviceManager.start();
......@@ -189,8 +192,27 @@ app.use(errorHandler());
/**
* Start Express server.
*/
app.listen(app.get('port'), function() {
console.log('Express server listening on port %d in %s mode', app.get('port'), app.get('env'));
});
const isSecure = process.env.TLS_ENABLED == 'true' ? true : false;
var server;
if (isSecure) {
const options = {
key: fs.readFileSync(process.env.PRIVATE_KEY_PATH),
cert: fs.readFileSync(process.env.CERT_PATH)
};
server = https.createServer(options, app).listen(app.get('port'), () => {
//logger.info('SSL Express server listening on port %d in %s mode', app.get('port'), app.get('env'));
});
} else {
server = http.createServer(app).listen(app.get('port'), () => {
//logger.info('Express server listening on port %d in %s mode', app.get('port'), app.get('env'));
});
}
if (process.env.REDIRECT_PORT) {
var redirectServer = http.createServer( (req,res) => {
res.writeHead(302, {'Location': process.env.REDIRECT_URL});
res.end();
}).listen(process.env.REDIRECT_PORT);
}
module.exports = app;
openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
cp server.key server.key.copy
openssl rsa -in server.key.copy -out server.key
rm server.key.copy
......@@ -29,7 +29,7 @@ exports.createToken = function(id, guestId, sessionId, callback) {
Token.findByDetails(id, guestId, sessionId, function(err, result) {
if (result == null) {
if (err) console.log('Token search failed:',err);
var host = "http://" + controller.ip + ":8080";
var host = "https://" + controller.ip + ":8080";
result = new Token({roomId: id, guestId: guestId, host: host, session: sessionId, role: 'guest'});
result.save(function(err, result) {
if (err) console.log("Token update failed");
......
......@@ -10,6 +10,7 @@
"test": "mocha --reporter spec --timeout 5000"
},
"dependencies": {
"amqp": "^0.2.6",
"async": "^2.0.0-rc.4",
"bcrypt-nodejs": "^0.0.3",
"bitgo": "1.5.4",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment