Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot pass mongo options to use cacert #6483

Open
heri16 opened this issue Aug 6, 2020 · 2 comments
Open

Cannot pass mongo options to use cacert #6483

heri16 opened this issue Aug 6, 2020 · 2 comments
Labels
enhancement For issues that describe a feature that needs to be added, changed, or removed, but is not a bug

Comments

@heri16
Copy link

heri16 commented Aug 6, 2020

https://github.com/reactioncommerce/api-core/blob/de2e924ae68247c08f690fbbd3fc9f678f4f45ec/src/util/mongoConnectWithRetry.js#L25

https://scalegrid.io/blog/mongodb-ssl-with-self-signed-certificates-in-node-js/

There is no way now to do the below on reaction.

var certFileBuf = fs.readFileSync(<path to CA cert file>);
var mongoUrl = 'mongodb://admin:blahblah@test0.servers.example.com:27017/admin?ssl=true';

var options = {
  replSet: {
    sslCA: certFileBuf
  }
};
var MongoClient = require('mongodb').MongoClient
  , assert = require('assert');

MongoClient.connect(mongoUrl, options, function(err, db) {
   assert.equal(null, err);
   console.log("Connected correctly to server");
   db.close();
 });
@novayadi85
Copy link

@focusaurus focusaurus added the enhancement For issues that describe a feature that needs to be added, changed, or removed, but is not a bug label Nov 18, 2020
@focusaurus
Copy link
Contributor

I agree this type of burying of key mongo connection options is not ideal. We need a way for the outermost application to provide mongo connection options. Complex types like a certFileBuf might require a real object to be passed through unless we want to model all the options as environment variables and support file paths, etc.

@zenweasel zenweasel transferred this issue from reactioncommerce/api-core Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement For issues that describe a feature that needs to be added, changed, or removed, but is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants