问题:如何在连接字符串中的pymongo mongoclient中提供pemfile密码?
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)
//现在我需要通过提供密码来连接。但我在pymongo文档和身份验证示例中没有看到任何参数
connection =
MongoClient(mongos_ip,int(mongos_port),ssl=True,ssl_certfile=sslpemkeyfile,ssl_ca_certs=sslCAFile)
//帮我解决这个问题!!!
答案 0 :(得分:1)
不幸的是当前版本的pymongo不支持此功能
答案 1 :(得分:0)
这个怎么样:
import ssl
connection = MongoClient(mongos_ip, int(mongos_port),
ssl=True,
ssl_certfile=sslpemkeyfile,
ssl_cert_reqs=ssl.CERT_REQUIRED,
ssl_ca_certs=sslCAFile)
来自这里:http://api.mongodb.org/python/current/examples/authentication.html