openssl genrsa -out CAroot.key 2048 openssl req -new -key CAroot.key -out CAroot.csr # CN should be different from the certificates below openssl req -x509 -days 1825 -key CAroot.key -in CAroot.csr -out CAroot.crt cat CAroot.crt CAroot.key > CAroot.pem openssl genrsa -out mongod.key 2048 openssl req -new -key mongod.key -out mongod.csr openssl x509 -req -days 1825 -in mongod.csr -CA CAroot.pem -CAkey CAroot.key -CAcreateserial -out mongod.crt cat mongod.crt mongod.key > mongod.pem openssl genrsa -out client.key 2048 openssl req -new -key client.key -out client.csr openssl x509 -req -days 1825 -in client.csr -CA CAroot.pem -CAkey CAroot.key -CAcreateserial -out client.crt cat client.crt client.key > client.pem mongo --ssl --sslCAFile CAroot.pem --sslPEMKeyFile client.pem --authenticationDatabase production -u user -p password --host mongo.host --port 27018