Allow passing SSL configuration into options for @key/postgres
See original GitHub issueI recently found that I was unable to use the keyv postgres backend because the production database I was connecting to forces SSL connections. This is a request to add the ability to pass SSL configuration options into the Keyv object. Or more generally to allow passing external pool for Keyv to make use of.
These are a sample of the errors I was getting:
Error from keyv.Keyv: error: no pg_hba.conf entry for host "3.89.49.50", user "postgres", database "postgres", SSL off
And the more cryptic message (this occurs after the above error):
TypeError: query is not a function
File "/app/node_modules/@keyv/postgres/src/index.js", line 29, col 19, in <anonymous>
.then(query => query(sqlString, values));
File "/app/node_modules/@keyv/postgres/src/index.js", in runMicrotasks
File "node:internal/process/task_queues", line 96, col 5, in processTicksAndRejections
Here’s a sample from my project of the SSL options:
import * as fs from 'fs';
import { Pool, PoolConfig } from 'pg';
function setupPgPool(): Pool {
const poolConfig: PoolConfig = {
connectionString:
process.env.DATABASE_URL ||
'postgres://postgres:postgres@localhost:5432/regen_registry',
};
if (process.env.NODE_ENV === 'production') {
poolConfig.ssl = {
ca: fs.readFileSync(`${__dirname}/../config/rds-combined-ca-bundle.pem`),
};
}
const pool = new Pool(poolConfig);
return pool;
}
const pgPool = setupPgPool();
export { pgPool };
Here’s an upstream issue with some additional info in case it is helpful. I would be glad to work on this once an approach is decided.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
PostgreSQL SSL Certificate Configuration - Alibaba Cloud
This article mainly discusses how to prevent Intermediate attackers and how to configure cert using certificates without password login.
Read more >Setting up SSL authentication for PostgreSQL - CYBERTEC
This blogposts helps you to set up SSL authetication for PostgreSQL and enables you to handle secure client server connections in the best ......
Read more >Documentation: 15: 34.19. SSL Support - PostgreSQL
PostgreSQL has native support for using SSL connections to encrypt client/server communications using TLS protocols for increased security.
Read more >How to Enable SSL authentication for an EDB Postgres ...
This guide describes the steps needed to enable SSL authentication for an EDB Postgres ... Verifying - Enter pass phrase for server.key:.
Read more >Using psql to connect to PostgreSQL in SSL mode
psql below 9.2 does not accept this URL-like syntax for options. The use of SSL can be driven by the sslmode=value option on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@wgwz - this should be going out in the next two weeks. Closing down this ticket.
The first approach where we pass the config into @keyv/postgres storage adapter would be the preferred.