Skip to content

Verify the Postgres certificate from the site and Ory - #131

Merged
bulbashenko merged 1 commit into
mainfrom
verify-db-ca
Oct 26, 2026
Merged

bulbashenko merged 1 commit into
mainfrom
verify-db-ca

Conversation

@bulbashenko

Copy link
Copy Markdown
Contributor

Часть 3 из 3, закрывает #94.

  • DSN сайта и Ory: sslmode=require → sslmode=verify-full&sslrootcert=/etc/internal-ca/ca.crt. Сайт больше не нуждается в uselibpqcompat=true: pg-connection-string 2.12 читает sslrootcert и с verify-full проверяет и CA, и имя.
  • site.yaml: монтирует ConfigMap internal-ca, secret-revision 2 → 3.
  • clusters/hel1/auth.yaml: патч Flux ставит на все Deployments auth аннотацию bulbashenko.com/secret-revision (так же, как у сайта). Без неё Ory не перечитал бы DSN, потому что env из Secret берётся только при старте пода. Сейчас аннотация "1", это перезапустит все 5 Deployments auth.
  • Из Secret auth убран неиспользуемый OIDC_COOLIFY_CLIENT_SECRET (хвост Coolify; клиента в Hydra нет с auth@3ad304a).

Stalwart переключается в bulbashenko-com/mail#7.

Порядок мержа

  1. Sign the Postgres server certificate with an internal CA #130 (CA, сертификат pg) live: kubectl -n data get cluster pg -o jsonpath='{.status.certificates.serverTLSSecret}' = pg-server-tls.
  2. Mount the internal CA into Kratos, Hydra and Keto auth#22 → его deploy/auth: Ory монтирует CA.
  3. Этот PR. Если смержить раньше п.2, Ory не найдёт /etc/internal-ca/ca.crt и упадёт на миграции.
  4. Verify the Postgres server certificate mail#7 → deploy/mail (можно в любой момент после п.1).

Проверка после

  • сайт открывается, /admin логин через Ory работает;
  • kubectl -n auth get pods: все Ready, рестартов нет;
  • в логах kratos/hydra/keto нет x509.

🤖 Generated with Claude Code

With pg serving a certificate from the internal CA and the CA mounted
in the pods, the site and Ory can stop accepting any certificate:
DSNs move from sslmode=require to verify-full with
sslrootcert=/etc/internal-ca/ca.crt. The site no longer needs
uselibpqcompat, which only kept node-postgres from verifying.

Ory reads its DSNs from the Secret only at pod start, and nothing
restarted it on a Secret change; the auth Flux Kustomization now stamps
a secret-revision annotation on its Deployments, the same knob the site
has. The unused OIDC_COOLIFY_CLIENT_SECRET leaves the Secret.

Closes #94.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bulbashenko
bulbashenko marked this pull request as ready for review October 26, 2026 21:56
@bulbashenko
bulbashenko merged commit 47932cf into main Oct 26, 2026
4 checks passed
@bulbashenko
bulbashenko deleted the verify-db-ca branch October 26, 2026 21:56
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.

1 participant