Repository navigation
fix(postgres): support or refuse the remaining libpq TLS parameters - #3416
Open
angela-helios wants to merge 2 commits into
Open
angela-helios wants to merge 2 commits into
angela-helios wants to merge 2 commits into
Conversation
…ions Read libpq's channel_binding (disable / prefer / require) from the connection URL next to sslmode, plus HFS_PG_CHANNEL_BINDING as a minimum for HFS. With require, a connection that was not authenticated with SCRAM-SHA-256-PLUS is refused, so sslmode=require resists a man-in-the-middle without a root certificate. deadpool-postgres does not pass its channel_binding field to the driver, so both pools are built through PostgresTlsSettings::pool_builder, which sets it on the tokio_postgres::Config. An unknown value, or require with sslmode=disable, refuses to start. The startup security log reports the mode. Closes #2764
Read sslcrl, sslnegotiation and ssl_min/max_protocol_version from the connection URL on HFS and HTS, plus HFS_PG_SSL_CRL on HFS. Any other ssl* parameter refuses to start instead of being ignored, and on Unix so does an sslkey file open to its group or others, by libpq's rule. sslpassword and sslcrldir are refused with a message. libpq's default files and PG* variables are documented as not read. Refs #2765
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #2765
This branch is stacked on the PR for #2764 (PR #3399): its diff includes that commit until #3399 merges.
Behaviour change to review
ssl*URL parameters now refuse to start. HFS ignored them (for example?ssl=true,?sslcompression=0or?SSLMODE=require); HTS already refused them through the driver. The message names the parameter and never its value.0600or less, or0640or less when root owns the file. A key mounted from a Kubernetes secret with the default mode (0644) needsdefaultMode.sslcrl,sslnegotiation,ssl_min_protocol_version,ssl_max_protocol_version. New variableHFS_PG_SSL_CRL(used when the URL has nosslcrl).sslcrlis stricter than libpq in two cases where libpq ignores the setting: a mode that does not verify the server certificate, and a file that cannot be read, both refuse to start.Summary
Each libpq TLS setting on a connection URL is now either supported or refused with a clear message.
ssl*URL parameterssslcrlHFS_PG_SSL_CRLssl_min_protocol_version,ssl_max_protocol_versionsslnegotiation=directsslmode=requireor strongersslpassword, encrypted client keysslcrldirsslcrl. libpq looks the files up by OpenSSL hash; rustls has no equivalent~/.postgresql/*default filesPG*environment variablespsqlwould start to change the servers. Both READMEs say they are not readsslcrl, every certificate of the chain except the trusted root needs a current list from its issuer, as in libpq. Revoked, not covered, or an expired list: the connection fails.verify-caandrequirewith a root certificate still do not check the host name.sslnegotiationis set inPostgresTlsSettings::driver_config, so both pools and the stored-view LISTEN connection use it. Withdirectthe client offers the ALPN protocol PostgreSQL requires.Tests
tls.rs): revoked, expired-list, uncovered and wrong-CA certificates; host name checked only byverify-full, also with a CRL;sslcrlrefused without verification or with an unusable file; the permission rule, plus a real file on Unix; encrypted key message; protocol version bounds;sslnegotiation=directper mode and in the driver configuration; URL parsing; refusal of unsupportedssl*parameters without their value.backend.rs): the URL parameters reachPostgresTlsSettings; the refusal names the variable and not the value.build_pool): both connection string forms forsslnegotiation, protocol versions, refusals.crl-ca.pem,crl-server.pem,crl-revoked.pem,crl.pem) incrates/persistence/tests/fixtures/pg_tls.sslcrl,sslnegotiation=director the protocol bounds.Results:
cargo test -p helios-persistence --libwith all backend features, filtered to the touched modules (among thembackends::postgres::tlsandbackends::postgres::backend::tests): 1202 passed.cargo test -p helios-hts --features postgres --lib url_tls_tests: 6 passed.cargo test -p helios-persistence --test postgres_tests postgres_tlsagainst PostgreSQL containers: 4 passed (existing tests; none covers the new settings).cargo test -p helios-hfs --bin hfs env_names: 7 passed.These ran on current
maintogether with three other pending fixes.