SSL cert for free tier

I have a free, shared tier of a MongoDB Atlas version 6.0.11 cluster an SSL is enabled, so how do I get the SSL cert required to connect to it? the simple connection string is not enough

Hi @Brennan_Ow,

What is the context regarding this question? I’d recommend going over the FAQ: Security documentation for Atlas.

Can you also verify what you mean by “the simple connection string is not enough”?

Regards,
Jason

Context: To connect to my free and shared tier cluster, I’m using the python code

uri = "mongodb+srv://<username>:<password>@cluster0.w029iod.mongodb.net/?retryWrites=true&w=majority"
client = MongoClient(uri, server_api=ServerApi('1'))

and sometimes it works, but sometimes I get the error stating that the SSL handshake failed.

I even tried using the X.509 method with and the SSL handshake failure error message still happens 50% of the time

client = MongoClient(uri,
tls=True,
tlsCertificateKeyFile=‘path/to/file.pem’,
server_api=ServerApi(‘1’))

What’s the pymongo driver version you’re using and what’s the full error message being generated?

Regards,
Jason

Thank you for continuing to follow up with me, but I have found a fix for it already. It turns out the ISP that I was using had some firewall configuration that did not allow me to connect to the cluster. So I outsourced the job of connecting to the cluster to a GitHub action where it’s ISP had no such issues.

I came to the conclusion after reading this → Error: couldn't connect to server 127.0.0.1:27017 - #16 by Stennie_X

specifically, this part

  • Your connection from client to server is blocked by firewall or network configuration

As for my pymongo version, it is 4.6.0

The error message was as follows

SSL handshake failed: <shard_id>.mongodb.net:27017: [WinError 10054] An existing connection was forcibly closed by the remote host (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)

Thank you for your time

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.