I am very close to getting my mongodb database connected in the App Platform. I built up the env value like this
mongodb+srv://${db-mongodb.USERNAME}:${db-mongodb.PASSWORD}@${db-mongodb.HOSTNAME}/testing?authSource=admin&replicaSet=db-mongodb&tls=true&tlsCAFile=${db-mongodb.CA_CERT}
I get this error Error: ENOENT: no such file or directory, open ‘-----BEGIN CERTIFICATE-----’ which makes me think there is another thing like tlsCAFile but to point to a string instead, as the App Platform is giving me this CA_CERT through the ENV. I think it will work once I get this.
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
Indeed, in order to connect to MongoDB, you need to specify the location of the certificate file rather than passing the certificate as a string to the connection string.
One way to do that is to create the file in your app’s code, before initializing the MongoDB connection. Here is an example for MongoDB:
fs.writeFileSync(path.resolve(__dirname, "mongodb.ca.crt"), process.env.CA_CERT)
Hope that this helps!
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.