Skip to content

Commit 4dbc11c

Browse files
author
Mohammad Hunan Chughtai
authored
(DOCSP-7893): added python client connection for x509 (#584)
* (DOCSP-7893): added python client connection for x509 * updated client opts to tls instead of ssl * removed unneeded import + filter * update db and collection names * moved to uri pattern for pymongo x509 snippet * docCount -> doc_count
1 parent e0d5b77 commit 4dbc11c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# begin x509 connection
2+
from pymongo import MongoClient
3+
4+
uri = "mongodb+srv://<cluster-url>/test?authSource=$external&retryWrites=true&w=majority&authMechanism=MONGODB-X509"
5+
client = MongoClient(uri,
6+
tls=True,
7+
tlsCertificateKeyFile='/etc/certs/mongodb/client.pem')
8+
9+
db = client['testDB']
10+
collection = db['testCol']
11+
doc_count = collection.count_documents({})
12+
print(doc_count)
13+
# end x509 connection

0 commit comments

Comments
 (0)