user3156089
user3156089

Reputation: 17

How to provide pemfile password in pymongo mongoclient in the connection string

Question: How to provide pemfile password in pymongo mongoclient in the connection string?

import pymongo
from pymongo import MongoClient

    sslCAFile = data['COMMON_SETTINGS']['sslCAFile']  //reading cafile path from configurationfile
    sslpemkeyfile = data['COMMON_SETTINGS']['sslpemkeyfile'] //reading pemfile path from configurationfile(which is encrypted with password)

// now i need to connect by giving the password . but i dont see any parameter for that in pymongo documentation and in authentication examples

    connection = 
    MongoClient(mongos_ip,int(mongos_port),ssl=True,ssl_certfile=sslpemkeyfile,ssl_ca_certs=sslCAFile)

//Help me on this!!!

Upvotes: 2

Views: 1219

Answers (2)

Sarath Nair
Sarath Nair

Reputation: 2868

Unfortunately the current version of pymongo doesn't support this feature

ref: https://jira.mongodb.org/browse/PYTHON-640

Upvotes: 1

J. P. Petersen
J. P. Petersen

Reputation: 5031

What about this:

import ssl

connection = MongoClient(mongos_ip, int(mongos_port),
                         ssl=True,
                         ssl_certfile=sslpemkeyfile,
                         ssl_cert_reqs=ssl.CERT_REQUIRED,
                         ssl_ca_certs=sslCAFile)

It is from here: http://api.mongodb.org/python/current/examples/authentication.html

Upvotes: 0

Related Questions