Mongodb – Connection string for connecting mongo database with SSL enabled

encryptionmongodbssl

Am facing some below problem in my mongodb replication environment

I have 3 replica set environment with SSL enabled and ssl mode as preferSSL

3 servers has 3 different Key file with common CA file

when i try to connect the mongo shell with below command it works fine

mongo –ssl –host hostname:port –sslPEMKeyFile "/home/mongod/keyfile.pem" –sslCAFile /home/mongod/CAfile.pem

My question is how to provide these details in connection string to connect the database from application perspective

MongoDB version: 4.0.2
OS: Amazon Linux

Thanks,
Vignesh

Best Answer

It depends on which driver you are using. https://docs.atlas.mongodb.com/driver-connection/#driver-examples