Encrypting the Zitadel database connection with TLS

Zitadel sends identity data, secrets and sessions to PostgreSQL on every request, so the connection needs TLS. This page explains the sslmode options, how to mount the CA in Kubernetes and why managed databases should never use disable.

On this page

Encrypting the Zitadel database connection with TLS: when and why teams need it

A platform or security team preparing a production Zitadel that uses an external PostgreSQL should treat the database link as a path that must be encrypted and verified, not assumed to be private. Zitadel stores identity data there, including users, credentials, sessions and configuration, so every connection from the Zitadel API and Login components to the database carries sensitive material. When the database runs on another host, in another subnet, or behind a managed service endpoint, that traffic crosses network segments your team may not fully control.

The connection is configured through the data source name (DSN) that Zitadel uses to reach PostgreSQL. Zitadel's documentation describes three sslmode values for that DSN: disable (no TLS), require (TLS without certificate verification) and verify-full (TLS with CA and hostname verification). The difference matters. require protects against passive eavesdropping but does not prove the server is the database you expect, so an attacker positioned on the network path could impersonate it. verify-full closes that gap by checking the server certificate against a trusted CA and the hostname. Self-hosted Zitadel supports PostgreSQL versions 14 through 18, so confirm your chosen server version is in that range before you set TLS parameters, and check the Zitadel database documentation for the current supported list.

Before rollout, confirm three things with your database and platform owners: which CA signed the server certificate, whether the certificate's hostname matches the address in the DSN, and where the CA file will be mounted in each Zitadel container. Those answers decide whether verify-full works on the first attempt. Plan a test against a staging database and record the sslmode value in your configuration review so auditors and operators can see the setting without reading the running process.

Which sslmode fits each database setup

This table compares the three sslmode settings Zitadel's Kubernetes database guide describes, along with the certificate files each one needs and the setups where it fits. Read each row against your own database: the main takeaway is that disable is for local test setups only, and any database reached over a network should use verify-full where your provider or CA allows it.

SetupsslmodeWhat it protects againstCertificate files and fit
Local test database on the same hostdisableNothing on the wire; relies on the host being trustedNo certificate files. Acceptable only for throwaway evaluation, never production.
Database on a private network, certificate not yet provisionedrequirePassive eavesdropping; does not verify the server identityNo CA file needed, but the server certificate is not checked. Treat as a temporary step, not a target state.
Self-managed PostgreSQL in your data center or cloud accountverify-fullEavesdropping and connections to an impostor server, with CA and hostname checksMount the internal CA certificate and make the DSN hostname match the server certificate subject.
Managed database such as RDS, Cloud SQL or Azure Databaseverify-full (disable not acceptable)Same as verify-full, using the provider's CA chainConfirm which CA bundle the provider publishes for your region and whether it is intermediate-signed, then mount that bundle.
Database reached through a connection pooler or proxyverify-full at the proxy hopEncrypts the client leg; the pooler-to-database leg needs its own TLS settingConfirm the pooler terminates TLS with a certificate Zitadel trusts and that the upstream leg is also encrypted.

How the Zitadel to PostgreSQL connection is verified

The connection starts at a Zitadel pod or binary in the application network and crosses into the database network. Under sslmode=verify-full, Zitadel's PostgreSQL client checks that the server certificate chains to the CA mounted into the Zitadel runtime and that the hostname in the certificate matches the host in the DSN. Check both the CA mount path and the hostname entry, because either failure stops the connection.

Zitadel verifies the PostgreSQL certificate across the trust boundary under verify-full.

Setting up verify-full for Zitadel in Kubernetes

This sequence moves the Zitadel database connection from unverified TLS to verify-full, so Zitadel only connects to a PostgreSQL server whose certificate chains to your CA and matches the host named in the DSN.

  1. Confirm TLS is enabled on the PostgreSQL server

    The database team checks that the PostgreSQL server has ssl turned on, with a server certificate and private key readable by the PostgreSQL service account. From a shell on a machine that can reach the database, run openssl s_client -starttls postgres -connect <db-host>:5432 (or use the TLS settings your managed service shows) and confirm the handshake completes and the certificate is not expired. Done means the server presents a certificate you can read and its subject alternative names include the exact host name Zitadel will use. If the server cannot negotiate TLS, fix that before touching Zitadel, because verify-full will fail against it.

  2. Obtain the CA certificate that signed the server

    Get the root or intermediate CA certificate that issued the PostgreSQL server certificate from your internal PKI team or your managed database provider's documentation. Save it as a PEM file, for example ca.crt, and confirm it chains to the server certificate with openssl verify -CAfile ca.crt server.crt. Done means the command reports OK. Do not copy the CA's private key anywhere, and do not use a CA bundle you cannot trace to a named issuer. Keep a record of the CA's expiry date so the renewal is planned.

  3. Create the Kubernetes secret with the CA certificate

    In the namespace where Zitadel runs, create a secret that holds only the CA certificate, for example with kubectl create secret generic zitadel-db-ca --from-file=ca.crt=ca.crt -n <namespace>. A config map also works for a public CA certificate, but a secret keeps the material out of plain configuration listings and matches how most teams store trust material. Done means kubectl get secret zitadel-db-ca -n <namespace> -o yaml shows a ca.crt key, and the decoded value matches the PEM file you verified in the previous step. Confirm with your platform team who can read this secret.

  4. Mount the CA certificate into the Zitadel container

    Add a volume that references the secret and a volume mount in the Zitadel deployment, using the Helm chart values or your manifest. Mount the secret read-only at a fixed path such as /etc/zitadel/db-ca, so the file appears as /etc/zitadel/db-ca/ca.crt. Apply the change and let the pods roll. Done means kubectl exec into a running Zitadel pod shows the file at that path and it is readable by the container user. If the pod does not start, check the secret name and namespace first, since a missing secret blocks scheduling.

  5. Set the DSN with verify-full and sslrootcert

    Update the database connection settings so the DSN uses sslmode=verify-full and sslrootcert pointing at the mounted file, for example sslrootcert=/etc/zitadel/db-ca/ca.crt. Set the host to the exact name listed in the server certificate, not an IP address or a Kubernetes service alias that the certificate does not cover. Keep the database password in a secret, not in the DSN in plain values. Done means the rendered configuration shows the expected host, verify-full and the sslrootcert path, and the password is referenced from a secret. Ask the Zitadel chart maintainers or your Helm values reference to confirm the exact key names for your chart version.

  6. Check the server name and the verified connection

    Confirm the host in the DSN matches a name in the server certificate's subject or subject alternative names. A quick check is openssl x509 -in server.crt -noout -ext subjectAltName, compared with the host Zitadel uses. Then check the running connection: review the Zitadel pod logs for database connection errors, and where your PostgreSQL server exposes it, confirm from the database side that the client connection uses SSL. Done means Zitadel starts without certificate errors and the database reports an encrypted session. A hostname mismatch or an untrusted chain at this point means the DSN or the CA is wrong, not that verify-full should be relaxed to require.

Differences for Kubernetes, Compose and binaries

In a Kubernetes deployment, the CA certificate is usually stored as a Kubernetes secret and mounted into the Zitadel pods as a file, and the DSN points at that file path. This keeps the certificate out of the container image and lets the platform team rotate it by updating the secret and rolling the deployment. The Helm values for the database connection and any extra volumes must be confirmed against the chart version you run, because key names change between releases.

  • Create the secret: Store the CA bundle in a secret in the same namespace as the Zitadel release, using a key name you will reference in the volume definition.
  • Mount it read-only: Add a volume from the secret and mount it into the API and any setup job that connects to PostgreSQL, so each pod that dials the database can read the CA.
  • Set the DSN path: Point the sslrootcert parameter in the DSN at the mounted file and set sslmode to verify-full.
  • Cover the setup job: The init and setup jobs also connect to the database, so a missing mount there fails the install even when the running pods are correct.
  • Plan rotation: Updating the secret does not change a running pod's files until the rollout completes, so schedule the restart with the CA change.

Confirm the exact values keys and mount options in the Zitadel Helm chart and the Kubernetes database documentation for your chart version before you edit production values.

Security controls around the database link

TLS protects the connection between Zitadel and PostgreSQL, but it is one control among several. The cards below cover the surrounding decisions that determine whether that link stays trustworthy over the life of the deployment.

Certificate rotation and expiry monitoring

The CA and server certificates behind verify-full expire on a schedule set by whoever issued them. When a certificate lapses, Zitadel cannot reach its database and the service fails at startup or during normal operation. Record the expiry date of every certificate in the chain, alert well before it, and confirm how the Zitadel pods or processes pick up a renewed CA file. Ask your team whether rotation requires a restart and whether that restart is covered by your change process.

Restricting network access to the database

Allow connections to PostgreSQL only from the Zitadel workloads and the administrators who maintain them. In Kubernetes this usually means a NetworkPolicy on the database service, and outside Kubernetes it means firewall rules and the listen_addresses setting. Verify the rule from a host that is not part of the Zitadel network, because a TLS-protected port that any internal host can reach still widens the attack surface.

SCRAM password authentication

Use SCRAM-SHA-256 for every Zitadel database role. PostgreSQL 18 deprecated MD5 password authentication in favor of SCRAM, so new roles should be created with SCRAM hashes and existing MD5 roles should be migrated. Check password_encryption on the server and the pg_hba.conf rule that matches the Zitadel connection, since a permissive older rule can override a strong default.

Masterkey kept apart from database credentials

The masterkey encrypts secrets Zitadel stores, so it should not sit in the same secret, file or vault path as the database DSN. Keep the database password and the masterkey in separate stores with separate access lists, so that someone who reads the connection string cannot also decrypt stored secrets. Confirm with your team who can read each one and how each is rotated.

Audit logging on the database

Enable PostgreSQL logging for connection attempts, authentication failures and role changes so that failed TLS or password attempts leave a trail. Review which statements are logged, since verbose logging of queries can capture sensitive data. Decide where logs are shipped, how long they are kept, and who can read them, and confirm that these settings match the retention rules your organization already applies to identity systems.

Authentication methods PostgreSQL offers

PostgreSQL documents several client authentication methods, including password, GSSAPI, SSPI, LDAP, RADIUS, certificate, PAM and OAuth. Each is configured per host and user in pg_hba.conf. This page does not claim that Zitadel supports each of them, so confirm with the Zitadel database documentation which methods its connection settings accept before you choose one. Certificate-based client authentication is the method to evaluate if you want the database to verify the Zitadel client as well as the server.

PostgreSQL auth methods

Why managed PostgreSQL should never use disable

Managed PostgreSQL services such as Amazon RDS, Google Cloud SQL and Azure Database for PostgreSQL should never be connected with sslmode=disable. A managed database endpoint usually sits on shared network infrastructure and is reachable from paths the operator does not fully control, so a Zitadel connection without TLS sends the database role's password, the SQL it runs and the identity data it returns in readable form. Zitadel holds user records, credentials and client configuration in that database, so the exposure is the same as the identity system itself. The only case where disable is defensible is a loopback or private socket that never leaves the host, and even then the reader should document that decision and confirm the network path with the platform team.

Setting sslmode=require encrypts the session, which stops passive observers on the network from reading traffic. It does not check who is on the other end. Without certificate verification, a client accepts any certificate presented to it, so an attacker who can redirect traffic to a spoofed server can receive the database password and return falsified data. That is why verify-full is the target for production: it validates the certificate chain against a trusted CA and checks that the certificate matches the hostname Zitadel connects to. Before choosing it, confirm with each provider's documentation which CA bundle its endpoints use, where that bundle is published, and whether the provider rotates it. Those CA bundles change over time, so the Zitadel deployment needs a documented process for updating the mounted certificate, not a one-time copy.

Limits to confirm before you change the DSN

Changing the database connection string touches several components at once: Zitadel, PostgreSQL, any proxy in the path and the certificate authority. Confirm each limit in your own environment before you edit the DSN, because a mismatch usually shows up as a failed startup rather than a clear error message.

Zitadel version and DSN options

Confirm which Zitadel release you run and which sslmode values its database documentation describes for that release. The Kubernetes database guide covers disable, require and verify-full, but other DSN parameters and certificate path keys may differ by version. Read the documentation for your exact release, not the current one, and test the DSN in a non-production instance first.

Kubernetes database docs

PostgreSQL version in the supported range

Check that your PostgreSQL server is on a major version Zitadel supports, and that the TLS settings you choose match what that server version provides. Also confirm whether the server is still within PostgreSQL's support window, since an end-of-life server will not receive security fixes for its TLS libraries. Plan any major upgrade separately from the TLS change.

Supported major versions
14 to 18
PostgreSQL versioning policy

Proxies in the connection path

Determine whether PgBouncer or another pooler sits between Zitadel and PostgreSQL. Each hop has its own TLS session, so verify-full must be configured on the hop that Zitadel connects to, and the pooler must present a certificate Zitadel trusts. Confirm that the pooler's server-side connection to PostgreSQL is also encrypted, otherwise the protection ends at the pooler.

PgBouncer documentation

Certificate lifetimes and renewal

Record the validity period of the server certificate and who renews it. An expired certificate under verify-full stops Zitadel from connecting, so confirm the renewal process, whether it restarts or reloads PostgreSQL, and whether Zitadel pods pick up a replaced CA without a manual restart. Add an alert that fires well before expiry.

CA coverage of the hostname

Verify that the certificate's subject alternative names include the exact host name in the DSN, including any internal DNS alias or load balancer name. verify-full checks the hostname as well as the chain, so a certificate issued for a different name fails even when the CA is correct. Test the name with a client outside the cluster as well as from inside it.

CA mounting and trust store

Confirm how the CA file reaches the Zitadel container, whether through a Kubernetes secret or config map mounted at a fixed path, and that the path in the DSN matches it. Check that the CA bundle used by the managed or private database is the one you mount, because a managed service may rotate its CA on its own schedule.

Questions teams ask about Zitadel database TLS

What does it cost to encrypt the Zitadel database connection with TLS?

The direct cost is the engineering time to change the DSN, provision certificates and verify the connection, plus any database-side work to enable TLS. Turning on TLS adds no license fee, because PostgreSQL is released under the PostgreSQL License, a liberal open source license similar to the BSD or MIT licenses. The main cost drivers are how many environments need changes, whether the database already presents a certificate your team can trust, how many Zitadel components connect to it, and whether certificate rotation is automated. Ask a partner for a written scope that lists each environment, the certificate source, who performs each change and how the work is verified before and after the switch.

How long does a TLS change to the Zitadel database usually take?

The duration depends mostly on access and approvals rather than on the configuration change itself. A single environment with a database administrator available and a CA bundle already issued usually moves faster than a multi-environment rollout that needs new certificates, change windows and security sign-off. Work to plan for includes confirming the current sslmode, testing verify-full against a staging database, updating the Kubernetes secret or mounted file, restarting Zitadel and checking logs. Ask any partner to state the expected duration per environment in the written scope, along with the dependencies that could move it.

What does our team need to provide before a partner starts?

Three things are needed early: administrative access to the PostgreSQL server or managed database settings, the CA certificate chain that signed the database server certificate, and access to the Kubernetes cluster or host where Zitadel runs. Database access should include the ability to confirm the server certificate, the database hostname and whether TLS is already enabled. For Kubernetes, the team should be able to create or update a secret or ConfigMap and mount it into the Zitadel pods. Confirm in advance who holds these credentials, how they will be shared, and whether the work happens in a change window your organization controls.

Can our own engineers do this without a partner?

Yes, in many environments. The work is a set of well-defined steps: choose the sslmode, obtain the CA, mount it, update the DSN and verify the connection. Teams with experience running PostgreSQL and Kubernetes can usually handle it, provided they test verify-full in a non-production environment first. A partner adds value when the database is shared across systems, when certificate issuance crosses several teams, or when the team needs evidence for an assessment. Whichever path you choose, document the sslmode, the CA source and the verification results so the configuration can be reviewed later.

Why does sslmode disable fail for regulated or production workloads?

The sslmode disable setting sends database traffic without TLS, so credentials and data can be read by anyone with network visibility between Zitadel and PostgreSQL. Zitadel's Kubernetes database guide describes disable as no TLS, require as TLS without certificate verification, and verify-full as TLS with CA and hostname verification. Require protects against passive sniffing but does not prove the server is the database you intended to reach. For production, verify-full is the setting that a security reviewer will expect to see, and it should be the default target for any environment that holds real identity data.

What changes when Zitadel uses a managed PostgreSQL service?

Managed databases such as those offered by cloud providers usually expose a server certificate that clients should verify, so sslmode disable should never be used there. The team typically has no superuser access, so the database role and database must be pre-provisioned, and the CA bundle must come from the provider's documented chain. Connection limits, pooling and failover behavior also change the plan. Ask a partner to confirm which managed service, which role model and which sslmode will be used, and to list any provider-side settings that the internal team must change.

What should we ask a partner to include in a written TLS scope?

A useful written scope names the environments in scope, the sslmode for each one, the source and renewal process for the CA certificate, and how the Kubernetes secret or file mount will be handled. It should list the verification steps, such as confirming the connection with verify-full, checking Zitadel logs and rerunning a failed connection test. It should also state what the internal team must provide, the change window needed, the rollback path and the deliverables, such as a configuration record. Fixed-scope engagements agree these items in writing before work starts, so ask for them explicitly.

How DeployOpen scopes and delivers Zitadel database TLS

DeployOpen plans the PostgreSQL connection for your Zitadel deployment as part of the wider platform build, in infrastructure you control. The work starts from your database setup, whether it is self-managed or a managed service, and ends with a documented, tested sslmode configuration that your security and compliance teams can review.

How we scope

  • Inventory where Zitadel connects to PostgreSQL, including the DSN source, the database host and the network path between them.
  • Agree the target sslmode (verify-full for most production setups) and who owns the CA certificate and its renewal.
  • Confirm the PostgreSQL version against the supported range and agree the scope in writing before any work begins.

How we build

  • Configure the DSN and mount the CA certificate into the Zitadel pods or host so verify-full succeeds without hostname errors.
  • Test each sslmode in a non-production environment and confirm that a plaintext connection is refused where policy requires TLS.
  • Set PostgreSQL server-side TLS and client certificate settings to match the agreed design, and record every change in configuration files.

How we hand over

  • Deliver a written runbook covering the DSN keys, certificate locations, expiry dates and the steps to rotate the CA certificate.
  • Provide verification evidence showing the connection mode in use, the tests run and the results, for your compliance review.
  • Walk your platform and database teams through the configuration so they can operate and troubleshoot it after handover.

How we support

  • Fixed-scope engagements are agreed in writing with deliverables and timelines, and changes go through a documented scope update.
  • Ongoing support, upgrades and continuous testing are available as a retainer, including reviews after PostgreSQL minor or major upgrades.
  • Ask any quote to separate one-time build effort from recurring certificate rotation, monitoring and upgrade work.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.