twisted / txmongo

asynchronous python driver for mongo
https://txmongo.readthedocs.io
Apache License 2.0
338 stars 102 forks source link

txmongo with DocumentDB #285

Closed radifalco closed 1 year ago

radifalco commented 1 year ago

Hey there, I'm trying to use txmongo with DocumentDB, I think my problem is with the *.pem file that DocumentDB URI requires. I'm setup like this:

        from twisted.internet import ssl as twisted_ssl

        # Load the RDS Combined CA Bundle file into a bytes object
        with open('rds-combined-ca-bundle.pem', 'rb') as f:
            ca_cert_bytes = f.read()

        # Create an SSL context with the RDS Combined CA Bundle
        ssl_context = twisted_ssl.CertificateOptions(
            trustRoot=twisted_ssl.Certificate.loadPEM(ca_cert_bytes)
        )
        self.conn = yield ConnectionPool(databaseURI, ssl_context_factory=ssl_context)

I get this error:

pymongo.errors.AutoReconnect: TxMongo lost connection to MongoDB.

You can get the PEM file here:

wget https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem

And the connection string is essentially this:

mongodb://user:pw@<host>:27017/my-db?serverSelectionTimeoutMS=2000&ssl=true&ssl_match_hostname=false&ssl_ca_certs=rds-combined-ca-bundle.pem&readPreference=secondaryPreferred

I'm thinking this is a me issue rather than an txmongo issue but I'm posting it in case I'm wrong about that. Thanks!