feat(ssl): supporting a certificate authority bundle file for the secured SSL configuration (#1342)

This commit is contained in:
Liran Tal
2016-06-07 09:58:02 +03:00
parent fde27f0d1e
commit c364922f67
2 changed files with 11 additions and 1 deletions

View File

@@ -4,7 +4,8 @@ module.exports = {
secure: {
ssl: true,
privateKey: './config/sslcerts/key.pem',
certificate: './config/sslcerts/cert.pem'
certificate: './config/sslcerts/cert.pem',
caBundle: './config/sslcerts/cabundle.crt'
},
port: process.env.PORT || 8443,
// Binding to 127.0.0.1 is safer in production.

View File

@@ -19,9 +19,18 @@ module.exports = function (app, db) {
// Load SSL key and certificate
var privateKey = fs.readFileSync(path.resolve(config.secure.privateKey), 'utf8');
var certificate = fs.readFileSync(path.resolve(config.secure.certificate), 'utf8');
var caBundle;
try {
caBundle = fs.readFileSync(path.resolve(config.secure.caBundle), 'utf8');
} catch (err) {
console.log('Warning: couldn\'t find or read caBundle file');
}
var options = {
key: privateKey,
cert: certificate,
ca: caBundle,
// requestCert : true,
// rejectUnauthorized : true,
secureProtocol: 'TLSv1_method',