Skip to content

Implement SSL verify-full and verify-ca - #311

Open
plambert wants to merge 2 commits into
will:masterfrom
plambert:ssl-verify-modes
Open

plambert wants to merge 2 commits into
will:masterfrom
plambert:ssl-verify-modes

Conversation

@plambert

@plambert plambert commented Sep 8, 2026

Copy link
Copy Markdown

Changes sslmode=verify-full and sslmode=verify-ca to no longer accept plaintext connections--only sslmode-require did so before.

Adds a method #ssl_required? to answer whether SSL must be negotiated.

Adds a method #resolved_sslrootcert to get the path to the SSL root certificate; this is determined from $PGSSLROOTCERT and/or the sslrootcert parameter, and defaults to ~/.postgres/root.crt on Linux/Darwin, or %APPDATA%/postgresql/root.crt on Windows.

Both modes were accepted, but still allowed plaintext connections,
making them less secure than sslmode=require. This patch adds a
`#ssl_required?` method that solves that problem.

For `sslmode=verify-full` it just uses the default context, which
enforces both CA and host/ip agreement. For `sslmode=verify-ca` there is
a callback defined that ignores host/ip disagreements but otherwise
passes through any errors.

Root certificate resolves from sslrootcert, PGSSLROOTCERT, and then
~/.postgresql/root.crt.

I updated the test CA with the minimum necessary to chain from it, and
added a server SAN. The tests of the combinations all pass.
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.

1 participant