How to connect to mongodb cluster using ssl ca

I have mongodb database cluster in scalegrid, but I can’t connect to it with just like this :

MONGO_URL=mongodb://admin:password@SG-Brain-77777.servers.mongodirector.com:27017/admin?ssl=true meteor run

I tried to use simple mongo connection in terminal

mongo mongodb://admin:password@SG-Brain-77777.servers.mongodirector.com:27017/admin?ssl=true

and stil cant connect with same error :
SSL peer certificate validation failed: self signed certificate

and I tried to make it like this :

mongo mongodb://admin:password@SG-Brain-77777.servers.mongodirector.com:27017/admin?ssl=true --ssl --sslCAFile ./.crt

and it works!!!

the problem now, i cant add --ssl --sslCAFile ./.crt in MONGO_URL like this, because it makes error :

MONGO_URL=mongodb://admin:password@SG-Brain-77777.servers.mongodirector.com:27017/admin?ssl=true --ssl --sslCAFile ./.crt meteor run

how to add ssl cert to mongo url?


new update I tried :

MONGO_URL=mongodb://admin:password@SG-Brain-77777.servers.mongodirector.com:27017/admin?ssl=true,ssl_ca_certs=./.crt meteor run

and got error :

MongoNetworkError: failed to connect to server [sg-brain-77777.servers.mongodirector.com:27017] on first connect [MongoNetworkError: connection 0 to sg-brain-77777.servers.mongodirector.com:27017 closed

I’ve just had the same problem and I’ve found the solution in the Meteor API docs (https://docs.meteor.com/api/collections.html#mongo_connection_options_settings)
which I found from this stackoverflow reply https://stackoverflow.com/a/62153405

I finally had to add my public IP (whether the one on your dev machine if connecting to the remote db, or your hosting provider’s) to the list of CIDR IPs (under Firewall Rules).

Hope this helps