TL;DR
This guide explains how to manage CA (Certificate Authority) certificates throughout their lifecycle – from creation and renewal to revocation and replacement. It covers key concepts, tools, and best practices for keeping your systems secure.
1. Understanding the Certificate Lifecycle
A certificate’s life isn’t forever. Here’s what happens:
- Creation: A CA issues a new certificate after verifying your identity and domain ownership.
- Usage: The certificate is used to encrypt communications (e.g., HTTPS for websites).
- Renewal: Certificates expire! You need to renew them before they do to avoid service disruptions.
- Revocation: If a certificate’s private key is compromised, it must be revoked immediately.
- Replacement: After revocation, a new certificate is issued.
2. Creating Certificates
You can get certificates in two main ways:
- Public CAs (e.g., Let’s Encrypt, DigiCert): These are trusted by most browsers and devices automatically. They require payment or meeting specific criteria for free options like Let’s Encrypt.
- Private CAs: You run your own CA infrastructure. This gives you more control but requires significant effort to maintain trust (e.g., distributing root certificates).
Using openssl is a common way to create Certificate Signing Requests (CSRs) which are then submitted to the CA:
openssl req -newkey rsa:2048 -nodes -keyout mydomain.key -out mydomain.csr
3. Automating Renewal
Manual renewal is error-prone. Automation is key.
- Certbot (Let’s Encrypt): A popular tool for automatically obtaining and renewing Let’s Encrypt certificates. It integrates with web servers like Apache and Nginx.
- ACME Protocol: Certbot uses the ACME protocol, which allows automated certificate management. Other tools also support it.
- Cron Jobs/Scheduled Tasks: Use these to run renewal scripts regularly (e.g., weekly).
Example certbot command for automatic renewal:
certbot renew --dry-run
(The --dry-run flag tests the renewal process without actually making changes.)
4. Revoking Compromised Certificates
If a private key is lost or stolen, revoke the certificate *immediately*.
- Public CAs: Follow their revocation procedures (usually through an online portal). They typically involve submitting the serial number of the certificate.
- Private CAs: Revoke the certificate in your CA database and publish a Certificate Revocation List (CRL) or use Online Certificate Status Protocol (OCSP).
A CRL is a list of revoked certificates. OCSP provides real-time revocation status checks.
5. Replacing Certificates
After revoking, get a new certificate:
- Generate a new CSR: As in step 2.
- Request a new certificate: From your CA.
- Install the new certificate: Configure your web server or application to use it.
6. Monitoring and Alerts
Don’t wait for errors! Proactive monitoring is vital.
- Expiry Dates: Track certificate expiry dates using a spreadsheet, dedicated monitoring tool, or scripting.
- Automated Notifications: Set up alerts to notify you well in advance of expiration (e.g., 30, 60, 90 days).
- Regular Audits: Periodically review your certificate infrastructure and processes.
7. Best Practices for cyber security
- Secure Private Keys: Store private keys securely (e.g., using hardware security modules – HSMs). Limit access to them.
- Short Validity Periods: Use shorter certificate validity periods (e.g., 90 days) for increased security, especially with automated renewal.
- Strong Algorithms: Use strong cryptographic algorithms (e.g., RSA with at least 2048-bit keys or ECC).
- Regular Updates: Keep your CA software and related tools up to date.

