fix(ssl): sslmode=prefer negotiates TLS without cert verification#726
fix(ssl): sslmode=prefer negotiates TLS without cert verification#726
Conversation
|
REV: fix(ssl): sslmode=prefer negotiates TLS without cert verification SummaryAPPROVE with one actionable note and one scope issue to resolve before merge. 1. Correctness of make_tls_config_require for preferThe function is correctly repurposed here. Using 2. Semantics match psql/libpqpsql 3. Fallback logic and the broad Err(_) armThis is the one actionable concern. With the old code, any TLS failure — including cert rejection — caused fallback to plaintext. That was wrong but the cert rejection was itself the bug. With The new code still catches The Require arm correctly propagates all errors with Err(ConnectionError::SslNotSupported) | Err(ConnectionError::TlsError(_)) => {
(connect_plain(pg_config, params).await?, None)
}
Err(e) => return Err(e),This preserves psql semantics (fall back when TLS is unavailable or handshake fails at the transport layer) while propagating auth failures and other non-TLS errors. Not a blocker given the behavior was pre-existing, but worth a follow-up issue. 4. Missing cfg.ssl_mode(TokioSslMode::Require)The Require, VerifyCa, and VerifyFull arms all clone 5. Code reuse / duplicationNo concern. 6. Out-of-scope changesCHANGELOG.md adds an 0.8.1 entry and Cargo.toml bumps the version from 0.8.0 to 0.8.1. Version management for 0.8.1 is tracked in PR #720. These changes should be removed from this PR to avoid a merge conflict or double-bump, or coordination with #720 confirmed explicitly. DecisionAPPROVE conditional on removing the CHANGELOG.md and Cargo.toml version bump before merge (or confirming coordination with #720). The core fix is correct. The broad |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #726 +/- ##
=======================================
Coverage 68.79% 68.79%
=======================================
Files 46 46
Lines 30998 30999 +1
=======================================
+ Hits 21324 21325 +1
Misses 9674 9674 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
52f3588 to
c9eb1dc
Compare
Closes #722
psql sslmode=prefer tries TLS first and falls back to plaintext only if TLS is unavailable — it does not verify the certificate. rpg was using webpki roots for prefer, causing fallback to plaintext on self-signed certs.
Fix: use the no-verify TLS config (same as sslmode=require) for the prefer TLS attempt.