Skip to content

Error: Unable to get local issuer certificate when using AWS RDS Proxy with @fastify/mysql #1041

Closed
@21020620

Description

@21020620

What are you trying to achieve, or the steps to reproduce?

I am trying to connect to an RDS Proxy endpoint (Proxy is connected to an RDS MySQL instance) with my node server running on Amazon Linux 2023 EC2 instance. The node server is using the Fastify framework, and to connect to the Proxy, I am using the @fastify/mysql plugin.
Link here: https://github.com/fastify/fastify-mysql.
The problem occurs if I enable "Require TLS" for the Proxy (if not, it is working fine).
So this is the code for the connection:

import fastifyMysql from "@fastify/mysql";
import { readFileSync } from "fs";

fastify.register(fastifyMysql, {
    host: process.env.MYSQL_HOST,
    user: process.env.MYSQL_USER,
    password: process.env.MYSQL_PASSWORD,
    database: process.env.MYSQL_DATABASE,
    promise: true,
    ssl: {
      ca: readFileSync('./ap-southeast-1-bundle.pem')
    }
});

What was the result you received?

When I try to run the server, it returns the error: Error: unable to get local issuer certificate

The .pem file was downloaded to the same directory with the code using: curl -o ap-southeast-1-bundle.pem https://truststore.pki.rds.amazonaws.com/ap-southeast-1/ap-southeast-1-bundle.pem

I would really appreciate if anyone can help!

Context

  • fastify version: latest
  • os: Amazon Linux 2023

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions