Skip to content

[Susan (Grok Bot)] chore: explicit pg sslmode=verify-full and channel binding - #13

Merged
glindsay65 merged 1 commit into
developfrom
chore/pg-ssl-verify-full
Nov 3, 2026
Merged

glindsay65 merged 1 commit into
developfrom
chore/pg-ssl-verify-full

Conversation

@glindsay65

@glindsay65 glindsay65 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Authored by Susan (Grok Bot), not Grant.

Why

Vercel function logs show the node-postgres warning that sslmode values prefer, require, and verify-ca are aliases of verify-full, and that pg 9 / pg-connection-string 3 will switch those aliases to weaker libpq semantics. The Neon Vercel integration owns DATABASE_URL, DATABASE_URL_UNPOOLED, and POSTGRES_URL_NON_POOLING. Those URLs end in ?channel_binding=require&sslmode=require, so the fix has to live in code.

pg 8.21.0 / pg-connection-string 2.13.0 copies channel_binding onto the parsed config and never reads it. Client.enableChannelBinding (pg/lib/client.js) stays false unless that constructor option is set. @types/pg 8.20.0 does not declare the option; the runtime does.

What changed

  • src/lib/pg-config.ts — pgPoolConfig() rewrites only sslmode=require|prefer|verify-ca to verify-full. disable, allow, verify-full, and a missing sslmode stay as they are, and sslmode is never added, so postgresql://localhost:5432/fdc_website is unchanged. channel_binding=require sets enableChannelBinding: true. The query param stays in the URL: constructing a client with it left in place emits no warning. Empty or invalid input is returned as a connectionString config. prismaDbPushUrl() appends sslaccept=strict when the URL has sslmode=require and no sslaccept, using & when a query string is already present and ? otherwise. sslmode=require stays in place for the schema engine.
  • src/lib/prisma.ts, scripts/sync-resume.ts, prisma/seed.ts — pools are created with pgPoolConfig(...). Scripts import the helper by relative path, the same way they already import src/lib.
  • scripts/print-prisma-db-push-url.ts, scripts/vercel-build.sh — prisma db push receives the strict URL for that command only. Seed still reads the original URL (DATABASE_URL_UNPOOLED or DATABASE_URL) and the pg helper rewrites sslmode to verify-full itself.
  • src/lib/pg-config.test.ts — vitest coverage for the sslmode rewrites, preserved params, channel binding, unset/empty input, and the db push URL.
  • scripts/dev.sh is unchanged (local Postgres, no sslmode).

Behavior

  • Runtime TLS verification is unchanged. pg 8 already treats sslmode=require as verify-full (ssl: {}, certificate check left at the Node default). The rewrite makes that explicit so the warning stops and pg 9 keeps the same verification.
  • Channel binding is now enabled. new pg.Client(pgPoolConfig('postgresql://u:p@host/db?channel_binding=require&sslmode=require')) has enableChannelBinding: true, ssl enabled, and emits no SECURITY WARNING. The same constructor with the raw sslmode=require URL still warns, and enableChannelBinding stays false.
  • prisma db push now verifies certificates via sslaccept=strict. Quaint in engines 7.8.0 only understands sslmode disable / prefer / require and would treat verify-full as prefer, so the push URL keeps sslmode=require.

Preview test plan

  • Preview deploy loads pages that read the database (home and a content page).
  • /api/sync and the sitemap respond.
  • Function logs have no SECURITY WARNING from pg.
  • The build log shows prisma db push succeeding (and seed, when SEED_DATABASE is set).

Verification

  • npm ci, npx tsc --noEmit, and npm run test:run (7 files, 61 tests) passed.
  • npx next build compiled and the TypeScript step finished. Static generation then failed with Can't reach database server at 127.0.0.1:1 because this environment has no Postgres.
  • npm run lint still reports existing issues in HeaderNav.tsx, SiteFooter.tsx, SiteHeader.tsx, and TestimonialSection.tsx. Those files are outside this diff. The files changed here are lint-clean.
  • This environment has no Neon connection, so the SCRAM handshake was not exercised against Neon. pg selects SCRAM-SHA-256-PLUS when enableChannelBinding is true, the connection is TLS, and the server offers that mechanism; otherwise it uses SCRAM-SHA-256 (pg/lib/crypto/sasl.js). Neon documents SCRAM-SHA-256-PLUS on direct and pooled connections. A pooler that omits the PLUS mechanism would still authenticate with SCRAM-SHA-256.
Open in Web Open in Cursor 

Rewrite Neon sslmode aliases for node-postgres, enable channel binding, and append sslaccept=strict for prisma db push.

Authored-by: Susan (Grok Bot)
Co-authored-by: Grant Lindsay <glindsay65@users.noreply.github.com>
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
website Ready Ready Preview Nov 3, 2026 7:00pm UTC

Request Review

@glindsay65
glindsay65 merged commit ef013ad into develop Nov 3, 2026
3 checks passed
@glindsay65
glindsay65 deleted the chore/pg-ssl-verify-full branch November 3, 2026 19:41

This branch was successfully deployed

1 active deployment
Preview — cf94e1f1 Deployed Nov 3, 2026 by vercel[bot]
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.

2 participants