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

有帮助吗?

解决方案

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

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

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top