Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
feat(mongodb): support for mongodb secure connections with ssl certif…
Browse files Browse the repository at this point in the history
…icates (#1472)

Fixes #1349
  • Loading branch information
lirantal authored Sep 3, 2016
1 parent cf246ba commit c0f6cb3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions config/env/production.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

var fs = require('fs');

module.exports = {
secure: {
ssl: true,
Expand All @@ -15,6 +17,20 @@ module.exports = {
options: {
user: '',
pass: ''
/**
* Uncomment to enable ssl certificate based authentication to mongodb
* servers. Adjust the settings below for your specific certificate
* setup.
server: {
ssl: true,
sslValidate: false,
checkServerIdentity: false,
sslCA: fs.readFileSync('./config/sslcerts/ssl-ca.pem'),
sslCert: fs.readFileSync('./config/sslcerts/ssl-cert.pem'),
sslKey: fs.readFileSync('./config/sslcerts/ssl-key.pem'),
sslPass: '1234'
}
*/
},
// Enable mongoose debug mode
debug: process.env.MONGODB_DEBUG || false
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"lusca": "~1.4.1",
"method-override": "~2.3.5",
"mocha": "~3.0.2",
"mongoose": "~4.4.8",
"mongoose": "~4.5.10",
"morgan": "~1.7.0",
"multer": "~1.2.0",
"nodemailer": "~2.5.0",
Expand Down

6 comments on commit c0f6cb3

@staminna
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using MEAN.JS but when I add this to config/env/secure.js

Could not connect to MongoDB!
MongoError: connection 0 to localhost:27017 closed

I have added the certification to mongod.conf and I am using Mongodb 3.2.x and mongoose 4.5.10.
mongod started with ssl enabled and the path to ssl certification is in place. Can you help?

@lirantal
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the individual server key options are deprecated per Automattic/mongoose#5442

Can you update the configs, test, and send us a PR to fix it?

@staminna
Copy link

@staminna staminna commented on c0f6cb3 Jul 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using a customized fork and I wouldn't know how. I wish I could.

@lirantal
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I make a change on a specific PR branch will you be able to test that code and see if it works?

@staminna
Copy link

@staminna staminna commented on c0f6cb3 Jul 7, 2017 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lirantal
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My PR is here: #1809
Basically just clone that branch or copy&paste the changes - they are incredibly small, I just removed the server{} object that is wrapping the SSL settings and now they are placed as part of the entire options object to Mongoose connection.

Please comment on the PR to see if it fixes the problem for you.

Please sign in to comment.