|
|
@@ -93,7 +93,7 @@ const mongoose = require('mongoose'); |
|
|
|
mongoose.Promise = global.Promise; |
|
|
|
|
|
|
|
// Connecting to the database |
|
|
|
mongoose.connect(dbConfig.url) |
|
|
|
mongoose.connect(dbConfig.url, {useNewUrlParser: true}) |
|
|
|
.then(() => { |
|
|
|
console.log("Successfully connected to MongoDB."); |
|
|
|
}).catch(err => { |
|
|
@@ -230,20 +230,23 @@ http.createServer (app) .listen (http_port, function () { |
|
|
|
var options; |
|
|
|
try { |
|
|
|
try { |
|
|
|
// In case it's a real certificate: add CA chain cersts (TODO: use array if required) |
|
|
|
var ca = fs.readFileSync ('keys/ca_cert.pem'); |
|
|
|
// In case it's a real certificate: add CA chain cersts (TODO: use array if required) |
|
|
|
var ca = fs.readFileSync ('keys/ca_cert.pem'); |
|
|
|
} catch (e) { |
|
|
|
ca = undefined; |
|
|
|
console.log ("Note: Can't read CA bundle: "+e); |
|
|
|
ca = undefined; |
|
|
|
console.log ("Note: Can't read CA bundle: "+e); |
|
|
|
} |
|
|
|
options = { |
|
|
|
key: fs.readFileSync ('keys/omkey.pem'), |
|
|
|
cert: fs.readFileSync ('keys/certificate.pem'), |
|
|
|
ca: ca |
|
|
|
}; |
|
|
|
https.createServer (options, app) .listen (https_port, function () { |
|
|
|
console.log ("Express https server listening on port " + https_port); |
|
|
|
}); |
|
|
|
if (ca != null) { |
|
|
|
|
|
|
|
options = { |
|
|
|
key: fs.readFileSync ('keys/omkey.pem'), |
|
|
|
cert: fs.readFileSync ('keys/certificate.pem'), |
|
|
|
ca: ca |
|
|
|
}; |
|
|
|
https.createServer (options, app) .listen (https_port, function () { |
|
|
|
console.log ("Express https server listening on port " + https_port); |
|
|
|
}); |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
console.log ("Note: Can't read SSL keys/certs: "+e+"\nDisabling https server"); |
|
|
|
} |