Documentation Index
Fetch the complete documentation index at: https://mintlify.com/cockroachdb/cockroach/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Thecockroach cert command creates and manages TLS certificates and keys for secure CockroachDB deployments. Proper certificate management is essential for production clusters.
Commands
create-ca
Create a Certificate Authority (CA) certificate and key.Directory where certificates will be stored. Created if it doesn’t exist.
Path to the CA private key file (e.g.,
my-safe-directory/ca.key).Certificate lifetime. Default is 10 years (87,600 hours).
RSA key size in bits. Common values: 2048, 4096.
Reuse existing CA key if it exists.
Overwrite existing certificates.
certs/ca.crt- CA certificate (distribute to all nodes)my-safe-directory/ca.key- CA private key (keep secure, needed to sign other certs)
create-node
Create a node certificate for server-to-server and client-to-server TLS.List of hostnames and IP addresses the node certificate will be valid for.
Include all addresses that clients and other nodes will use to connect: hostnames, IP addresses, and
localhost.certs/node.crt- Node certificatecerts/node.key- Node private key
create-client
Create a client certificate for SQL user authentication.SQL username for the certificate (e.g.,
root, app_user).certs/client.root.crt- Client certificate for userrootcerts/client.root.key- Client private key for userroot
certs/client.app_user.crtcerts/client.app_user.key
list
List all certificates in the certs directory.Complete Setup Guide
Create node certificate for each server
For each CockroachDB node, create a certificate with all its addresses:
Distribute certificates to nodes
Each node needs:
ca.crt(CA certificate)node.crt(node certificate)node.key(node private key)
ca.crtclient.<username>.crtclient.<username>.key
Certificate Files Reference
| File | Description | Distribution |
|---|---|---|
ca.crt | Certificate Authority certificate | All nodes and clients |
ca.key | CA private key (for signing) | Secure storage only, not on nodes |
node.crt | Node server certificate | Node servers |
node.key | Node private key | Node servers (same node as node.crt) |
client.root.crt | Client certificate for root user | Admin clients |
client.root.key | Client private key for root | Admin clients |
client.<user>.crt | Client certificate for SQL user | Application clients |
client.<user>.key | Client private key | Application clients |
Certificate Rotation
Certificates expire based on the--lifetime parameter (default 5 years for node/client certs). To rotate:
Troubleshooting
Error: x509: certificate signed by unknown authority
Error: x509: certificate signed by unknown authority
Error: x509: certificate is valid for X, not Y
Error: x509: certificate is valid for X, not Y
Connecting to a hostname not listed in the node certificate.Solution: Recreate the node certificate including all hostnames and IPs:
Permission denied errors
Permission denied errors
Incorrect file permissions on certificate or key files.Solution:
Security Best Practices
- Use strong key sizes (minimum 2048 bits, prefer 4096 for CA)
- Set appropriate certificate lifetimes (shorter for higher security)
- Rotate certificates before expiration
- Use separate client certificates for different applications
- Never commit private keys (
.keyfiles) to version control - Implement certificate expiration monitoring
- Consider using separate CAs for client and node certificates
Related Documentation
- Security Overview - Cluster security configuration
- Cluster Management - Certificate usage in clusters
- cockroach start - Starting secure nodes