Overview
Module ID:pki
The PKI app can define certificate authorities capable of signing certificates. Other modules can use these CAs for:
- Issuing certificates for internal services
- Establishing trust relationships
- Local development with valid HTTPS certificates
By default, Caddy creates a “local” CA that is used for signing locally-trusted certificates. The root certificate is automatically installed in the system trust store.
Configuration
Basic Structure
Certificate Authority Configuration
CA Parameters
User-facing name of the certificate authority.Default:
Caddy Local AuthorityCommonName field for the root certificate.Default:
{pki.ca.name} - {time.now.year} ECC RootSupports placeholders:{pki.ca.name}- The CA name{time.now.year}- Current year
CommonName field for intermediate certificates.Default:
{pki.ca.name} - ECC IntermediateLifetime for intermediate certificates.Default:
168h (7 days)Must be less than the root certificate lifetime.Whether to install the CA’s root certificate into system trust stores, including:
- System trust store (Windows, macOS, Linux)
- Java trust store
- Mozilla Firefox trust store
trueCustom root certificate and key configuration. If omitted, Caddy generates a root certificate automatically.See KeyPair Configuration below.
Custom intermediate certificate and key. If omitted, Caddy generates an intermediate automatically.See KeyPair Configuration below.
How often to check if certificates need renewal.Default:
10mFraction of certificate lifetime (0.0–1.0) after which renewal is attempted.For example,
0.2 means renew when 20% of the lifetime remains (~73 days for a 1-year cert).Default: 0.2Custom storage module for this CA’s certificates and keys, separate from Caddy’s global storage.Useful for keeping signing keys in a different location than leaf certificates.
KeyPair Configuration
For custom root or intermediate certificates:Path to the certificate file (PEM format)
Path to the private key file (PEM format)
Format of the certificate/key:
pem_file- PEM files on disk (default)
Multiple Certificate Authorities
You can define multiple CAs for different purposes:Default CA
The default CA has the IDlocal and is provisioned automatically if the PKI app is used. It provides:
- Automatic trust installation - Root certificate installed in system trust stores
- Automatic renewal - Intermediate certificates renewed before expiration
- Secure defaults - ECC (Elliptic Curve Cryptography) certificates
- Local development - Perfect for HTTPS in development without certificate warnings
Certificate Renewal
Caddy automatically manages certificate renewal for CAs:- Maintenance checks run at the interval specified by
maintenance_interval(default: 10 minutes) - Renewal threshold is calculated using
renewal_window_ratio(default: 20% of lifetime remaining) - Automatic regeneration of intermediate certificates before expiration
- Root certificate renewal if the root is managed by Caddy and approaching expiration
Root certificates have a default lifetime of 10 years. Intermediate certificates have a default lifetime of 7 days and renew automatically.
Storage Locations
By default, CA certificates and keys are stored at:{caddy_data_dir}is typically~/.local/share/caddyon Linux,~/Library/Application Support/Caddyon macOS, or%AppData%/Caddyon Windows{ca_id}is the CA identifier (e.g.,local)
Custom Storage Backend
Use a custom storage backend for a CA:Using Custom Root Certificates
Provide your own root certificate instead of having Caddy generate one:Trust Store Installation
Wheninstall_trust is enabled (default), Caddy attempts to install the root certificate in:
-
System trust store:
- Windows: Certificate Manager
- macOS: Keychain
- Linux: ca-certificates (Debian/Ubuntu) or ca-trust (RHEL/Fedora)
- Java trust store - If Java is installed
- Mozilla Firefox - If Firefox is installed
You may be prompted for administrator/sudo password during trust installation.
Disable Trust Installation
To prevent automatic trust installation:Security Considerations
- Private keys are stored with restrictive permissions (0600)
- Root certificates should be rotated every 10 years (or as per your policy)
- Intermediate certificates renew automatically every 7 days by default
- Trust installation may require administrator privileges
- Custom storage can be used to keep signing keys separate from leaf certificates