Connection Fails with "SSL off"
Problem Description
A client fails to connect to PostgreSQL and the server rejects the connection with an error similar to:
The key part is SSL off: the client connected without SSL, and no pg_hba.conf
rule matches a non-SSL (host) connection for that client, so PostgreSQL
rejects it.
Root Cause
pg_hba.conf only contains hostssl (SSL-only) entries for the client's
address range, or is missing a catch-all rule for the client. A client that
does not negotiate SSL therefore has no matching rule.
Diagnosis
Inspect the effective rules:
Confirm there is no host (or hostssl if the client does use SSL) rule that
matches the client's address.
Resolution
Add a matching rule under spec.patroni.pg_hba in the postgresql custom
resource. Prefer requiring SSL where possible:
Patroni reloads the configuration without a restart. See Configuring the pg_hba Client Authentication Whitelist for the full procedure and verification.
Adding host all all 0.0.0.0/0 md5 allows unencrypted password authentication
from any address. Prefer fixing the client to use SSL and keeping only
hostssl rules whenever possible.