Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encryption error when connecting to Postgres 16 #28

Open
icereed opened this issue Aug 1, 2024 · 3 comments · Fixed by #34
Open

Encryption error when connecting to Postgres 16 #28

icereed opened this issue Aug 1, 2024 · 3 comments · Fixed by #34

Comments

@icereed
Copy link

icereed commented Aug 1, 2024

Hello :)

Thanks firstly to provide this awesome lib.

I almost got it working but the provider fails to connect to the Postgres instance.
I saw that by default with Postgres 16 in RDS force_ssl is set to true.

Now I get this error when connecting:

no pg_hba.conf entry for host \"10.3.126.123\", user \"master\", database \"myDB\", no encryption

Usually when using pg, I would normally need to set the client option like this:

ssl: {
   rejectUnauthorized: true,
   ca: fs.readFileSync(path.join(__dirname, '../../../certificates/rds-combined-ca-bundle.pem')).toString(),
};

In the lambda I don't see any option to achieve this. Any ideas?

@berenddeboer
Copy link
Owner

I would say ssl should always be true? But to be honest, I haven't checked this is the case, I've simply assumed ssl is used out of the box.

Anyway, in handler.ts you see the code that connects to the database (line 293). So you could make changes there. However, it seems you are using a custom certificate? That seems to be the real issue?

To make this work, the provider would need to receive the path of a custom certificate, and this certificate must be uploaded with the lambda, so it has access to this. Something like that.

@djcass44
Copy link
Contributor

After a brief look at the pg source, this CustomResource will never use TLS as there is no way to set ssl: true or set the sslmode via the connection string.

It would be good to be able to provide a custom certificate, however even just tacking ssl: true in here would be a huge improvement.

I'm currently not able to use this CustomResource because our RDS instances only allow encrypted connection.

Given that it's a 1 line change I'd be happy to put up an MR

@berenddeboer
Copy link
Owner

Reverted commit. Couldn't make this build actually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants