Reputation: 1558
So being completely new to the NoSQL world, I decided to give mongodb a trial, and downloaded the following version, which I presumed supported ssl out of the box:
db version v3.2.4
git version: e2ee9ffcf9f5a94fad76802e28cc978718bb7a30
allocator: tcmalloc
modules: none
build environment:
distarch: x86_64
target_arch: x86_64
So when I run
mongod --sslMode requireSSL --sslPEMKeyFile C:\data\keys\server-key.pem --sslCAFile C:\data\keys\ca-crt.pem
I get the following error message:
Error parsing command line: unrecognised option '--sslMode'
try 'mongod --help' for more information
What am I missing here?
Upvotes: 8
Views: 31530
Reputation: 151
Faced the same issue while working on mongo-university's M001: MongoDB Basics course. The demo connection for the course expects a ssl connection but the mongo binary I had threw this error:
$ mongo "mongodb://primary:27017,replica1:27017,replica2:27017/test?replicaSet=Cluster0-shard-0" --ssl --authenticationDatabase admin --username <user_name> --password <password>
Error parsing command line: unrecognised option '--ssl'
try 'mongo --help' for more information
Root cause of the issue is that the mongo
binary provided in the community
edition does not support --ssl
option.
I downloaded the evaluation version for the enterprise edition and connected successfully the M001:demo mongo server.
More details are in mongo Jira issue SERVER:21622
Upvotes: 7
Reputation: 170
The selected answer is no longer valid. At the official docker images 4.2.0. (latest right now) and 4.0.1. from Dockerhub you can set the flags --sslMode respectively --tlsMode (Haven't tested other image tags).
Prerequisites
sudo docker volume create --name mongo-cert
LOCATION="$(sudo docker volume inspect mongo-cert | jq -r '.[0].Mountpoint')"
sudo openssl req -x509 -newkey rsa:4096 -keyout "$LOCATION/key.pem" -out "$LOCATION/cert.pem" -days 365 -nodes
touch $LOCATION/mongo.pem
cat $LOCATION/key.pem >> $LOCATION/mongo.pem
cat $LOCATION/cert.pem >> $LOCATION/mongo.pem
v4.2.0
sudo docker run --name mongo --rm -p 27017:27017 --mount source=mongo-cert,target="/cert" \
mongo:4.2.0 mongod \
--tlsMode "allowTLS" \
--tlsCertificateKeyFile "/cert/mongo.pem"
v4.0.1
sudo docker run --name mongo --rm -p 27017:27017 --mount source=mongo-cert,target="/cert" \
mongo:4.0.1 mongod \
--sslMode "allowSSL" \
--sslPEMKeyFile "/cert/mongo.pem"
Upvotes: 2