Skip to content

Commit 71468ba

Browse files
author
Mohammad Hunan Chughtai
authored
(DOCSP-7894): added ruby x509 snippet (#585)
* (DOCSP-7894): added ruby x509 snippet * updated url * updated rb example snippet
1 parent 5e69196 commit 71468ba

File tree

1 file changed

+11
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)