Question

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!!!

Was it helpful?

Solution

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

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top