Certificate Loaders
Certificate loaders are modules that load certificates into Caddy’s in-memory cache. All loaded certificates are pooled together and may be used to complete TLS handshakes for relevant server names (SNI).Automate Loader
Automatically manages certificates for the specified names, including obtaining and renewing certificates.Certificates are managed according to their matching automation policy configured elsewhere in the TLS app.
This is a special certificate loader that uses Caddy’s automation features rather than loading certificates manually.
Example
File Loader
Loads certificates and their associated keys from disk.Each entry specifies a certificate/key pair with optional tags.
Path to the certificate (public key) file.
Path to the private key file.
The format of the cert and key.Currently only
pem is supported.Arbitrary values to associate with this certificate.
Useful when you want to select a particular certificate when there may be multiple valid candidates.
Example
Folder Loader
Loads all certificate pairs from a directory:Certificate and key files should be in the same directory. Files are paired by matching names (e.g.,
example.com.crt with example.com.key).PEM Loader
Loads certificates from inline PEM text:Storage Loader
Loads certificates from Caddy’s configured storage:Certificate Cache
Caddy maintains an in-memory certificate cache for fast TLS handshakes.Maximum number of certificates to allow in the cache.If reached, certificates will be randomly evicted to make room for new ones.
Example
OCSP Stapling
Caddy automatically staples OCSP responses for all qualifying certificates.Disables OCSP stapling for manually-managed certificates only.To configure OCSP stapling for automated certificates, use an automation policy instead.
Example
Certificate Tags
Tags allow you to associate arbitrary metadata with certificates and select specific certificates during handshakes.Use Cases
- Differentiate between production and staging certificates
- Select certificates based on environment
- Route to specific certificates based on custom logic
Example with Selection
Mixed Manual and Automated
You can combine manual certificate loading with automated management:Caddyfile Configuration
Automated Certificates
Manual Certificate Loading
Self-Signed Certificate
Disable Automatic HTTPS
Global Certificate Loading
Certificate Lifecycle
Obtaining
-
Automated (ACME)
- Certificate requested from CA during startup or on-demand
- ACME challenges completed automatically
- Certificate stored in configured storage
-
Manual
- Certificate loaded from file or storage
- No automatic management
- Must be manually renewed before expiration
Renewal
Caddy automatically renews managed certificates before they expire. Default renewal window is 1/3 of the certificate’s lifetime.
- Certificate monitored for expiration
- Renewal attempted when renewal window is reached
- If successful, old certificate replaced with new one
- If failed, retries with exponential backoff
- 90-day certificate: Renews around day 60 (30 days before expiration)
- 12-hour certificate: Renews around hour 8 (4 hours before expiration)
Revocation
Revoke a certificate using the Caddy API:Storage
Certificates are stored in Caddy’s configured storage backend:- Default: File system at
$HOME/.local/share/caddyor$XDG_DATA_HOME/caddy - Alternatives: Consul, DynamoDB, S3, Azure, etc.
Custom Storage
Best Practices
Automated Certificates: Preferred for production. Let Caddy handle the entire lifecycle.
Certificate Cache: The default capacity (10,000) is suitable for most deployments. Increase if managing many domains.
Troubleshooting
Certificate Not Loading
- Check file paths are absolute and accessible
- Verify file permissions (Caddy must be able to read them)
- Ensure certificate and key match
- Check logs for detailed error messages
ACME Challenge Failures
- Verify DNS points to your server
- Ensure ports 80 (HTTP) or 443 (TLS-ALPN) are accessible
- For DNS challenge, verify DNS provider credentials
- Check CA rate limits (use staging for testing)
OCSP Stapling Issues
- Ensure OCSP responder URL is accessible
- Check network connectivity and firewall rules
- Verify certificate chain is complete
- Review OCSP override configuration if customized