我正在尝试使用 ssl 连接到 mongodb,如下所示,连接到 mongo 提示Enter PEM pass phrase:,如何避免此提示?
from pymongo import MongoClient
database_name = "iso_change_life_cycle_qa"
collection_name= "mymongocollection"
def get_db():
try:
# Following are the paths for certificates created by PIE environment. As long as
# your PIE app environment is authroized by PIE FDB SRE, following should just work.
client = MongoClient('iso-change-life-cycle-qa-s01.mongo-api.storage.pie.g.company.com',
ssl=True,
ssl_certfile='/Users/username/Documents/pythonscripts/change_lifecycle.apple.com.chain.pem',
ssl_keyfile='/Users/username/Documents/pythonscripts/change_lifecycle.apple.com.key.pem')
db = client[database_name]
return db
except Exception as e:
print (e.__str__())
def main():
while True:
try:
db= get_db()
print "db"
print db
except Exception as e:
print (e.__str__())
if __name__ == "__main__":
main()
错误:- 运行脚本提示
python testdb.py
Enter PEM pass phrase:
缥缈止盈
相关分类