Final exam question 3: default SSL mongoClient setting

Hey,
answering to the question

Suppose an instance of MongoClient is created with the default settings :

from pymongo import MongoClient uri = “mongodb+srv://m220-user:m220-pass@m220-lessons-mcxlm.mongodb.net/test” mc = MongoClient(uri) mc.stats

What will be the output of mc.stats?

My answer was

Database(MongoClient(host=['m220-lessons-shard-00-02-mcxlm.mongodb.net:27017', 'm220-lessons-shard-00-00-mcxlm.mongodb.net:27017', 'm220-lessons-shard-00-01-mcxlm.mongodb.net:27017'], document_class=dict, tz_aware=False, connect=True, authsource='admin', replicaset='m220-lessons-shard-0', **ssl=False**), 'stats')

with ssl=False.

I based my answer on this bit of the documentation at this URL
http://api.mongodb.com/python/current/api/pymongo/mongo_client.html

SSL configuration:

  • ssl: If True , create the connection to the server using SSL. Defaults to False .

Did I misinterpreted something? As the answer marked as correct, is said to have ssl=true.

True but, for Atlas clusters SSL is the default and is mandatory.

https://docs.mongodb.com/guides/cloud/connectionstring/

1 Like

The question does not specify “instance of MongoClient for an Atlas cluster”.

Because we used an SRV string, SSL is enabled by default for this connection.