Skip to content

Read PGSSLMODE - #1307

Merged
porsager merged 2 commits into
porsager:masterfrom
efeesrefinal:fix/pgsslmode
Nov 5, 2026
Merged

porsager merged 2 commits into
porsager:masterfrom
efeesrefinal:fix/pgsslmode

Conversation

@efeesrefinal

Copy link
Copy Markdown
Contributor

PGSSLMODE is ignored, so PGSSLMODE=verify-full connects without encryption and without any error. The option loop looks for PG + the option name, which is PGSSL, and libpq has no such variable.

ssl now reads PGSSLMODE. A url or an ssl option still comes first, and PGSSL still works. I added it to the table in the README.

This changes behaviour: anyone who has PGSSLMODE=require set against a server without TLS now gets an error instead of a plain connection.

Tested on PostgreSQL 15 and Node 22: require and verify-full give an encrypted connection, verify-full fails on an untrusted certificate, disable stays plain, and ?sslmode=disable wins over the variable. Unit tests pass, including a new one. I did not run the integration suite.

@porsager

porsager commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Thanks Efe, let’s take this in 4.1: a connection that fails because PGSSLMODE is now honoured is better than verify-full silently connecting in plain text.
Could you add a changelog entry saying it may change how existing setups connect (require now uses TLS, and verify-ca/verify-full check the certificate against Node’s CAs, not ~/.postgresql/root.crt or PGSSLROOTCERT)?

@efeesrefinal

Copy link
Copy Markdown
Contributor Author

Added, thanks. I also moved the test, so this and #1308 no longer conflict. The three open PRs merge cleanly together, and the unit tests and simulate.js pass on the result.

@porsager

porsager commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Thank you :)

@porsager
porsager merged commit 19db087 into porsager:master Nov 5, 2026
69 of 74 checks passed
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 this pull request may close these issues.

2 participants