Hello, I am working on a python project using MongoDB for several months now, I had no connect issue until today where I encounter a CERTIFICATE_VERIFY_FAILED problem that looks like this:
pymongo.errors.ServerSelectionTimeoutError: xxxx-shard-00-02.xxxxxx.mongodb.net:00000: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
I browse through the community forums and lucky found the problem:
My original code:
connection = "mongodb+srv://"+ username + ":" + password + "@xxxx.xxxxx.mongodb.net/Configurations?retryWrites=true&w=majority" client = pymongo.MongoClient(connection)
My new fixed code:
client = pymongo.MongoClient(connection, ssl_ca_certs=certifi.where())
So it had something to do with the
But I find this problem odd, why today? it has been working for months with no issues, and furthermore, which cacert.pem is the default “client = pymongo.MongoClient(connection)” using? Where is the problem originated from and how do I fix it at its core?
I would very much appreciate it if someone explains this to me.