Hello
I have an issue when trying connect to Atlas cluster on MacOS. On linux all work fine. Here is how i installed pymongo:
pip3 install pymongo
after I got the error, i additionally executed:
pip3 install dnspython
pip3 install pymongo[tls]
Here is error:
s = MongoClient(“mongodb+srv://xxx:yyy@cluster0.myfdu.mongodb.net”)
print(s[‘data’][‘test’].find_one())
Traceback (most recent call last):
File “”, line 1, in
File “venv/lib/python3.8/site-packages/pymongo/collection.py”, line 1319, in find_one
for result in cursor.limit(-1):
File “venv/lib/python3.8/site-packages/pymongo/cursor.py”, line 1207, in next
if len(self.__data) or self._refresh():
File “venv/lib/python3.8/site-packages/pymongo/cursor.py”, line 1100, in _refresh
self.__session = self.__collection.database.client._ensure_session()
File “venv/lib/python3.8/site-packages/pymongo/mongo_client.py”, line 1816, in _ensure_session
return self.__start_session(True, causal_consistency=False)
File “venv/lib/python3.8/site-packages/pymongo/mongo_client.py”, line 1766, in __start_session
server_session = self._get_server_session()
File “venv/lib/python3.8/site-packages/pymongo/mongo_client.py”, line 1802, in _get_server_session
return self._topology.get_server_session()
File “venv/lib/python3.8/site-packages/pymongo/topology.py”, line 490, in get_server_session
self._select_servers_loop(
File “venv/lib/python3.8/site-packages/pymongo/topology.py”, line 215, in _select_servers_loop
raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: cluster0-shard-00-00.myfdu.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123),cluster0-shard-00-02.myfdu.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123),cluster0-shard-00-01.myfdu.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), Timeout: 30s, Topology Description: <TopologyDescription id: 6012d175aa7e4741cc6ef1a0, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription (‘cluster0-shard-00-00.myfdu.mongodb.net’, 27017) server_type: Unknown, rtt: None, error=AutoReconnect(‘cluster0-shard-00-00.myfdu.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)’)>, <ServerDescription (‘cluster0-shard-00-01.myfdu.mongodb.net’, 27017) server_type: Unknown, rtt: None, error=AutoReconnect(‘cluster0-shard-00-01.myfdu.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)’)>, <ServerDescription (‘cluster0-shard-00-02.myfdu.mongodb.net’, 27017) server_type: Unknown, rtt: None, error=AutoReconnect(‘cluster0-shard-00-02.myfdu.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)’)>]>
Query work fine if add to connection tlsAllowInvalidCertificates=True. But that is bad solution.
Is it any issues with pymongo and MacOS, or may by i missed some dependency?
Thank you in advance