Encrypted Communication
TLS can provide transport encryption, server authentication, and client authentication. Configure each protection separately. Enabling server TLS does not make clients verify the server or make the server require client certificates.
Most TLS operational work involves certificate issuance, distribution, trust, and rotation. Without central management, services often skip verification or keep plaintext connections.
Pigsty manages PKI declaratively. Deployment creates a local self-signed CA, issues component certificates, and distributes trust. TLS is then ready for use.
Local CA
During initial deployment, Pigsty checks for a CA on the administration node. It creates one when required:
| File | Description | Permissions |
|---|---|---|
files/pki/ca/ca.key | CA private key and root of trust for the deployment; protect it carefully | 0600, with directory mode 0700 |
files/pki/ca/ca.crt | CA root certificate; safe to distribute | 0644 |
ca_createcontrols CA behavior. Pigsty reuses an existing key and certificate unchanged. If only the key exists, it issues a replacement certificate with that key.ca_create: falseprevents creation of a missing private key. Ifca.keyis absent, deployment stops instead of creating an unexpected trust root. Always back up and restoreca.keyandca.crttogether.ca_cnsets the certificate CN, defaultpigsty-ca. The key is RSA 4096.- The root CA is valid for 100 years. Component certificates default to 20 years (
cert_validity:7300d). The browser-facing Nginx certificate is an exception, with a current default of 397 days.
Long default lifetimes reduce initial maintenance for private infrastructure. Production still needs certificate rotation. Organizations with a certificate policy should shorten lifetimes and monitor expiration.
Trust Distribution
Every node must trust the CA. When managing a node, Pigsty copies the CA certificate to /etc/pki/ca.crt and links it into the OS trust store:
- EL family (RHEL, Rocky, Alma): link under
/etc/pki/ca-trust/source/anchors/and runupdate-ca-trust - Debian and Ubuntu: link under
/usr/local/share/ca-certificates/and runupdate-ca-certificates
Clients that use the OS trust store, such as curl, can then verify Pigsty CA certificates. The Nginx portal also publishes ca.crt at its site root for browsers and external clients.
By default, PostgreSQL libpq clients look for ~/.postgresql/root.crt and use sslmode=prefer. They do not directly use the OS trust store to verify server identity.
Server Identity Verification
Security-sensitive PostgreSQL clients should use sslmode=verify-full and specify the Pigsty CA:
verify-full checks the certificate chain and connection hostname. The server certificate SAN must contain the client’s DNS name or IP address. External clients must install ca.crt or specify it with sslrootcert.
Certificate Matrix
The local CA issues certificates for these components under one trust chain:
| Component | Certificate Identity (CN) | Deployment Path | Encryption State |
|---|---|---|---|
| PostgreSQL | <cluster>-<sequence> | /pg/cert/server.{crt,key} | Server-side SSL enabled by default; HBA determines whether it is mandatory |
| PgBouncer | Reuses the PostgreSQL certificate | /pg/cert/ | TLS disabled by default (pgbouncer_sslmode) |
| Patroni | Reuses the PostgreSQL certificate | /pg/cert/ | API HTTPS disabled by default (patroni_ssl_enabled) |
| etcd | <instance-name> | /etc/etcd/server.{crt,key} | TLS for client and peer traffic |
| Silo | <node-name> | ~minio/.minio/certs/ | Silo HTTPS is enabled by default (minio_https) |
| Kafka | <cluster>-<sequence> | /etc/kafka/pki/kafka.pem | SASL_SSL/SSL with kafka_security: scram; defaults to plaintext |
| MySQL | <instance-name> | /etc/mysql/pki/server.{crt,key} | Secure transport enforced; clients and group replication verify the certificate chain |
| Nginx | pigsty, with portal domains in SAN | /etc/nginx/conf.d/cert/ | HTTPS enabled by default (nginx_sslmode) |
| INFRA node | <node-name> | /etc/pki/infra.{crt,key} | Available to infrastructure components |
These defaults distinguish available TLS from enabled TLS:
- Enabled at deployment: PostgreSQL accepts SSL connections. etcd uses TLS for clients and peers.
- Encrypted by default: Object storage backup traffic through MINIO and Nginx web traffic use HTTPS.
- Available but disabled: Patroni API and PgBouncer TLS is disabled, with certificates already installed. Enable the corresponding parameters.
ha/safeenables both.
SSL support, mandatory encryption, and client verification of server identity are separate states. HBA enforces encryption with auth: ssl or cert. Client sslmode and trust settings control server verification. Default rules require TLS only for administrator connections from arbitrary sources. The safe template uses ssl or cert for main TCP rules. It retains local ident and selected localhost password rules.
Client Certificates
cert.yml issues client certificates. For HBA cert authentication, the certificate CN represents the database user name:
The files are files/pki/misc/<cn>.key and files/pki/misc/<cn>.crt. Deliver private keys through a controlled channel and allow only the corresponding user to read them. Client certificates let the server verify clients. The client must still use verify-full to verify the database server.
Using an Enterprise CA
Pigsty can issue certificates from an existing enterprise CA or an intermediate signed by its root. Put the certificate and private key at these paths. Playbooks reuse an existing CA:
Also set ca_create: false. Deployment then stops if the private key is missing, rather than creating a new trust root. However, an existing key with a missing certificate still causes certificate reissuance. Verify and restore both files together.
Key Protection and Rotation
- The CA private key exists only on the administration node. It and
pigsty.ymlare among the deployment’s highest-trust assets. Keep an offline backup. See Trust Boundaries. - If the CA key is compromised, establish a new trust root and reissue every component and client certificate. Plan a period of trust in both CAs to avoid interrupting all connections together.
- Component certificate sources reside at
files/pki/<component>/on the administration node. Node files are deployment copies. Deleting only a node copy restores the same certificate. To rotate, update or remove the source, rerun the relevant playbook, and reload or roll the component as required.
Next
- 🔑 Authentication: use HBA to decide who must use SSL or client certificates
- 🔒 Data Security: encryption for stored data and backups
- ✅ Compliance: evidence for certificate management
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)