How it works
- Cordon listens on a local port (e.g.,
15432) - Your app connects to
localhost:15432with no password - Cordon intercepts the PostgreSQL authentication handshake
- The real password, resolved when Cordon starts, is injected into the authentication handshake
- The authenticated connection is forwarded to the upstream database
PostgreSQL listeners currently resolve credentials at startup, not per connection. If you rotate the underlying secret, restart Cordon to pick up the new value.
Configuration
Database connections are configured as[[listeners]] entries in cordon.toml, alongside HTTP routes. See Listeners for the full configuration reference.
PostgreSQL listener upstreams are configured trust decisions in v1, matching configured HTTP credential routes. Cordon resolves the configured upstream once at listener startup and connects to the selected
SocketAddr, which pins DNS and avoids a second lookup before connecting. Private, loopback, and link-local upstream policy will be revisited post-v1 in #531.
Client TLS
PostgreSQL clients can request TLS from the local Cordon listener by sending a PostgreSQLSSLRequest before the startup packet. Configure client_tls on each listener:
Cordon uses the same local CA configured under
[tls] for PostgreSQL client TLS. Clients using sslmode=verify-ca or sslmode=verify-full must trust that CA, for example by running cordon trust or by configuring the client trust store directly.
Cordon presents a loopback certificate valid for localhost, 127.0.0.1, and ::1. For sslmode=verify-full, connect to the local listener with one of those host identities.
Cordon always requires TLS on the Cordon-to-upstream PostgreSQL leg. It sends a PostgreSQL
SSLRequest to the upstream server and completes TLS before sending startup or authentication data. If the upstream declines TLS or certificate verification fails, Cordon fails closed and does not send credentials.Connecting your application
Point your application at the local port instead of the upstream database:- Connection string
- Environment variable