Traceback (most recent call last):
File "pymongo_ssl.py", line 7, in <module>
print mongoClient.database_names()
File "/home/modak/.virtualenvs/enod-venv/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 1149, in database_names
"listDatabases")["databases"]]
File "/home/modak/.virtualenvs/enod-venv/local/lib/python2.7/site-packages/pymongo/database.py", line 491, in command
with client._socket_for_reads(read_preference) as (sock_info, slave_ok):
File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/home/modak/.virtualenvs/enod-venv/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 859, in _socket_for_reads
with self._get_socket(read_preference) as sock_info:
File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/home/modak/.virtualenvs/enod-venv/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 823, in _get_socket
server = self._get_topology().select_server(selector)
File "/home/modak/.virtualenvs/enod-venv/local/lib/python2.7/site-packages/pymongo/topology.py", line 214, in select_server
address))
File "/home/modak/.virtualenvs/enod-venv/local/lib/python2.7/site-packages/pymongo/topology.py", line 189, in select_servers
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: SSL handshake failed: EOF occurred in violation of protocol (_ssl.c:590)
Python代码
from pymongo import MongoClient
MONGO_URI='mongodb://localhost:27017'
mongoClient = MongoClient(MONGO_URI, ssl=True, ssl_ca_certs='ca-certs.pem')
print mongoClient.database_names()`