Repository navigation
fix(db): sslmode=verify-ca skips the hostname check, as libpq does - #859
Merged
Merged
Conversation
sqlx 0.8 skips the name check for verify-ca only when rustls returns CertificateError::NotValidForName; rustls 0.23.24 and later return NotValidForNameContext instead, so verify-ca behaved as verify-full. sqlx 0.9 accepts both (transact-rs/sqlx#3861). It needs Rust 1.94. This matters for Cloud SQL private-IP instances: their server certificate names only the instance's DNS name with a trailing dot, which rustls never accepts as a presented name, so neither verify-full nor (until now) verify-ca could connect. - sqlx 0.8.2 -> 0.9.1; Rust 1.91.0 -> 1.94.0 (toolchain, Dockerfiles). - sqlx 0.9 API: ArgumentBuffer has no lifetime; [u8; N] also implements Type/Encode for Any, so the bytea new-types name Postgres; the one dynamic query is marked AssertSqlSafe (only numbered placeholders are interpolated). - Tests: verify_ca_still_checks_the_hostname becomes verify_ca_skips_the_hostname_check; new tests for a Cloud SQL style certificate (trailing-dot name) and an unknown CA under verify-ca. - db.url docs describe verify-ca as it now behaves. Co-Authored-By: Claude Opus 5.5 <[email protected]>
sqlx 0.9 takes SQL as SqlSafeStr; the fixture loader passes the repository's own SQL files. Co-Authored-By: Claude Opus 5.5 <[email protected]>
cjorge-thegraph
marked this pull request as ready for review
November 21, 2026 15:17
MoonBoi9001
pushed a commit
that referenced
this pull request
Nov 23, 2026
🤖 I have created a release *beep* *boop* --- ## [0.3.4](v0.3.3...v0.3.4) (2026-11-23) ### Added * **config:** type secrets as such and read config from several files ([#857](#857)) ([fe92407](fe92407)) * **db:** connect to Postgres over TLS ([#847](#847)) ([2673181](2673181)) * **db:** let only 1 dipper process write, enforced by the database ([#858](#858)) ([6f88900](6f88900)) * **db:** make the database password optional ([#850](#850)) ([cb5d3b1](cb5d3b1)) * **metrics:** serve Prometheus metrics and optionally log as JSON ([#851](#851)) ([523819e](523819e)) * **rpc:** expose effective indexing targets and chain identity ([#860](#860)) ([aafc0ce](aafc0ce)) * **startup:** wait for Postgres and IISA instead of exiting ([#849](#849)) ([d1406d4](d1406d4)) ### Fixed * **db:** sslmode=verify-ca skips the hostname check, as libpq does ([#859](#859)) ([5fec97d](5fec97d)) * **k8s:** roll dipper out one pod at a time ([#846](#846)) ([de57e46](de57e46)) * **shutdown:** stop taking jobs first and fit the teardown in its budget ([#854](#854)) ([a1bc47d](a1bc47d)) ### Tests * run each test's Postgres on its Unix socket only ([#861](#861)) ([bc9e2b2](bc9e2b2)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
sslmode=verify-canow skips the hostname check, as libpq does, so dipper can verify a Cloud SQL private-IP instance's certificate.Problem
DNS:d0b150ab5022.76ws9odrdkfn.us-central1.sql-psa.goog.. rustls (webpki) never accepts a presented name with a trailing dot, soverify-fullcan't connect, whatever the URL says.verify-cashould be the answer (check the chain againstsslrootcert, skip the name), but with sqlx 0.8 it behaves asverify-full. sqlx'sNoHostnameTlsVerifierswallows onlyCertificateError::NotValidForName, while rustls ≥ 0.23.24 returnsCertificateError::NotValidForNameContext. dipper's own testverify_ca_still_checks_the_hostnamerecorded exactly this and said to update the docs once a later sqlx fixed it.invalid peer certificate: certificate not valid for name "<host>"; certificate is only valid for DnsName("<host>."). It runs withsslmode=require(encrypted, unverified) until this lands.Fix
rust-toolchain.toml, both Dockerfiles;rust:1.94.0-slim-bookwormexists), which sqlx 0.9 requires.ArgumentBufferhas no lifetime.[u8; N]now also implementsType/EncodeforAny, so the bytea new-types namePostgres.AssertSqlSafe, because only numbered placeholders are interpolated and the values are bound.db.urldescribesverify-caas it now behaves, with Cloud SQL as the example.Tests
verify_ca_still_checks_the_hostname→verify_ca_skips_the_hostname_check.verify_ca_accepts_a_cloud_sql_certificate(a CA-signed certificate whose only name has a trailing dot),verify_full_refuses_a_cloud_sql_certificate_even_by_its_name(whyverify-cais the mode to use there) andverify_ca_still_refuses_a_certificate_from_an_unknown_ca(the chain is still checked).cargo clippy --all-targets -- -D warnings --force-warn deprecated -D dead-code: clean.cargo +nightly fmt --check: clean.db::tests: 12/12).tests::it_): 12 passed, 0 failed (pgtemp Postgres); the public-API integration tests (--test '*') run in CI.Not in this PR
db.urlfromsslmode=requiretosslmode=verify-ca.🤖 Generated with Claude Code