Repository navigation
feat(db): Supabase with TLS verified against its private CA - #11
Merged
Merged
Conversation
Supabase certificates chain to "Supabase Root 2021 CA", which no system
trusts. The app pool and the Prisma CLI read TLS differently, so:
- backend/certs/supabase-prod-ca-2021.crt: official root, fingerprint
matched against the one the pooler serves
- lib/databaseTls.ts: DATABASE_URL stays plain; DATABASE_CA_CERT becomes
ssl: { ca } for pg and sslaccept=strict&sslcert= for migrations
- measured in the production image: CLI verify-full+sslrootcert accepts a
wrong CA; only sslaccept=strict rejects wrong CA and wrong host
- fail closed: production needs TLS on the database; a CA plus ssl* URL
parameters is refused (pg lets the URL override the CA)
- Dockerfile ships certs/ and the helper to the generate stage
- ADR 53, deployment guide rewritten for the session pooler
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully 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.
Why
The database moves from Neon (paused, free compute quota) to Supabase. Supabase's certificates chain to a private root CA, and the app's
pgpool and the Prisma CLI read TLS settings differently — a plainsslmode=requireeither fails (app) or connects without checking the certificate (migrations).What
backend/certs/supabase-prod-ca-2021.crt— official root, SHA-25680:70:25:AD…E6:CA:FA, matched against the root the pooler serveslib/databaseTls.ts—DATABASE_URLstays as Supabase gives it;DATABASE_CA_CERTbecomesssl: { ca }for pg andsslaccept=strict&sslcert=for the CLIssl*URL parameters is refused everywhererender.yamlsetsDATABASE_CA_CERT; Dockerfile shipscerts/Verified in the production image (no password needed — non-existent tenant)
Plus:
verify-full&sslrootcertin the Prisma CLI accepts a wrong CA — recorded in ADR 53, never emitted.452 backend tests pass (14 new in
tests/unit/database-tls.test.ts).Deploy order
DATABASE_URLmust be the Supabase session pooler string (port 5432) with no?sslmode=— the old Neon URL has one and would be refused with this change.