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

MongoDB secure connection with certificates #1349

Closed
pasket opened this issue May 24, 2016 · 4 comments
Closed

MongoDB secure connection with certificates #1349

pasket opened this issue May 24, 2016 · 4 comments

Comments

@pasket
Copy link

pasket commented May 24, 2016

We have found some errors with the data types in mongodb connections using certificates. Finally, we have solved:

  1. Updating mongoose to:
    "mongoose": "^4.4.16",
  2. We have configured our secure connection like this:

'use strict';
var fs = require('fs');
...
...
db: {
uri: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI ||
'mongodb://172.16.1.66/mycollection',
options: {
user: 'avalverde',
pass: 'mypass...',
server: {
ssl: true,
sslValidate: false,
sslKey:
fs.readFileSync('./config/sslcerts/mongoose/metabox-key.pem'),
sslCert:
fs.readFileSync('./config/sslcerts/mongoose/metabox-cert.pem'),
sslCA: fs.readFileSync('./config/sslcerts/mongoose/ca.pem')
}
},
...
...

  1. Finally, we had to edit config/lib/mongoose.js because the buffer of the certificates weren't Uint8Array as expected. We added the following lines.

    if ( config.db.options && config.db.options.server ) {
    config.db.options.server.sslCert = new Uint8Array(config.db.options.server.sslCert);
    config.db.options.server.sslKey = new Uint8Array(config.db.options.server.sslKey);
    }

    var db = mongoose.connect(config.db.uri..................

@lirantal lirantal self-assigned this Jun 15, 2016
@lirantal
Copy link
Member

Hi @pasket,

Would you like to submit a PR for this enhancement?

@lirantal lirantal added this to the 0.5.0 milestone Jun 15, 2016
@pasket
Copy link
Author

pasket commented Jun 21, 2016

Yes. Thank you.

@lirantal
Copy link
Member

lirantal commented Jul 7, 2016

@pasket we can't wait... :)
are you on it or do you need some help?

@ilanbiala
Copy link
Member

@pasket if you open a PR, we'll review it and help tidy up any loose ends. Any work that you have would help us wrap this up.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants