By nickynick
Here is my connection code :
this.connection = mysql.createConnection({
host: 'xxxx.db.ondigitalocean.com',
user: 'doadmin',
port: 25060,
password: 'xxxx',
dialect: 'mysql',
force: true,
ssl: {
cert: fs.readFileSync(__dirname + '/ca-certificate.crt'),
}
});
Here is the error im getting
(node:5676) UnhandledPromiseRejectionWarning: Error: self signed certificate in certificate chain
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!
I’m experiencing the exact same issue. The certificate provided by DO doesn’t make a connection possible from my local computer to the managed DB. I’d really appreciate some input on how to use it within a node.js application and one of the available mysql drivers.
So far I couldn’t find any solutions online, which unfortunately prevents me from actually using DO :/
ssl: {
ca: fs.readFileSync(__dirname + '/ca-certificate.crt'),
}
Change cert attribute to ca You can even add rejectUnauthorized: true
Hi @nickynick,
Usually when experiencing this issue is when you are using a SELF SIGNED certificate, is that correct?
If that’s the case, add NODE_TLS_REJECT_UNAUTHORIZED='0' as an environment variable wherever you are running node or running node directly with NODE_TLS_REJECT_UNAUTHORIZED='0' node app.js
This instructs Node to allow untrusted certificates (untrusted = not verified by a certificate authority)
I would not recommend setting this environment variable in production as your application would not be trusted by users. You can use free Let’s Encrypt certificates.
Regards, KDSys
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.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.