Here is an example of a client application connecting using TLS:
import pprint
from pymongo import MongoClient
client = MongoClient(
username='read_all',
password='password',
authSource='admin',
authMechanism='SCRAM-SHA-256',
host='server.biglittle.local',
tls=True,
tlsCAFile='/etc/.certs/test-ca.pem',
tlsCertificateKeyFile='/home/ked/test-client.pem');
result_biglittle = client.biglittle.users.find_one({},{"name":1,"address":1})
pprint.pprint(result_biglittle)
Here is a screenshot showing the results of the test run:
For this example, we modified /path/to/repo/chapters/12/test_read_all.py (described earlier in this chapter) to now incorporate TLS options. As you can see from the modified version of the file shown here, we configure the application to use the read_all user, assigned the readAnyDatabase role. TLS settings include...