mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 07:30:04 +00:00
feat(db): present a Postgres client certificate from sslcert and sslkey in TREK_DB_URL
A Postgres server that authenticates clients by certificate could not be used: TREK read only sslmode and sslrootcert from TREK_DB_URL, so neither the connection pool nor pg_dump, pg_restore and psql ever offered a client certificate (discussion #3215). TREK_DB_URL now also takes libpq's sslcert and sslkey. Both must be given together and only with a verifying sslmode, and each file must be readable, or the boot refuses with the same kind of message as for sslrootcert. The pool gets them as its TLS cert and key, the tools as PGSSLCERT and PGSSLKEY. The Postgres wiki page shows the URL, how to mount the files with Compose or the chart's extraVolumes, and libpq's rule for the key file's permissions, which the backup tools enforce.
This commit is contained in:
@@ -97,6 +97,21 @@ describe('pg-tools', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('PGTOOLS-023: the client certificate in sslcert and sslkey reaches the tools as PGSSLCERT and PGSSLKEY', () => {
|
||||
const env = pgConnectionEnv(
|
||||
'postgres://u@h/d?sslmode=verify-full&sslrootcert=%2Fcerts%2Fca.crt&sslcert=%2Fcerts%2Fclient.crt&sslkey=%2Fcerts%2Fclient.key',
|
||||
);
|
||||
expect(env).toMatchObject({
|
||||
PGSSLMODE: 'verify-full',
|
||||
PGSSLROOTCERT: '/certs/ca.crt',
|
||||
PGSSLCERT: '/certs/client.crt',
|
||||
PGSSLKEY: '/certs/client.key',
|
||||
});
|
||||
const plain = pgConnectionEnv('postgres://u@h/d?sslmode=require');
|
||||
expect(plain.PGSSLCERT).toBeUndefined();
|
||||
expect(plain.PGSSLKEY).toBeUndefined();
|
||||
});
|
||||
|
||||
it('PGTOOLS-004: pg_dump writes a private custom-format dump beside the target and renames it into place', async () => {
|
||||
installFakeTool(bin, 'psql', { snippets: [answersSchema()] });
|
||||
const log = installFakeTool(bin, 'pg_dump', { snippets: [writesFile('dump')] });
|
||||
|
||||
Reference in New Issue
Block a user