Production-grade guide to certificate lifecycle management covering architecture patterns, implementation strategies, testing approaches, and operational best practices for enterprise engineering teams.
Certificate Lifecycle Management is the process of provisioning, deploying, monitoring, rotating, renewing, revoking, and retiring digital certificates across a distributed system. It matters when services depend on TLS, mutual TLS, or PKI-based authentication—especially in microservices, hybrid cloud, and service mesh environments—where a single expired or misconfigured certificate can break end-to-end connectivity, compromise security, and trigger cascading outages.
Provisioning begins with generating a certificate signing request (CSR) and submitting it to a certificate authority (CA), either internal (e.g., HashiCorp Vault, CFSSL, OpenSSL) or external (e.g., Let’s Encrypt, AWS ACM, Google Cloud Certificate Manager).
A typical CSR is generated using openssl with a specific key and subject:
openssl req -new -newkey rsa:2048 -nodes -keyout app.key -out app.csr \
-subj "/C=US/ST=California/L=San Francisco/O=My Company/CN=api.mycompany.com"
The CSR is sent to the CA via HTTP POST:
POST /api/v1/certificates/requests HTTP/1.1
Host: ca.mycompany.com
Content-Type: application/pkcs10
-----BEGIN CERTIFICATE REQUEST-----
MIICyDCCAlACBB...
-----END CERTIFICATE REQUEST-----
The CA responds with a 201 Created and a Location header pointing to the request:
HTTP/1.1 201 Created
Location: /api/v1/certificates/requests/12345
Content-Type: application/json
{
"id": "12345",
"status": "pending",
"issuedAt": null,
"expiresAt": "2025-03-15T12:00:00Z"
}
The client polls this endpoint until status transitions to issued. Upon issuance, the CA returns the full certificate chain:
GET /api/v1/certificates/requests/12345 HTTP/1.1
Host: ca.mycompany.com
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "12345",
"status": "issued",
"certificate": "-----BEGIN CERTIFICATE-----\nMIIF...",
"chain": [
"-----BEGIN CERTIFICATE-----\nMIIF...",
"-----BEGIN CERTIFICATE-----\nMIIF..."
],
"issuedAt": "2024-03-15T12:00:00Z",
"expiresAt": "2025-03-15T12:00:00Z"
}
The service stores the certificate and private key in a secure vault or file system, then loads the certificate into its TLS stack.
Deployment involves distributing the certificate and key across services and environments. For Kubernetes, a Secret is the standard:
apiVersion: v1
kind: Secret
metadata:
name: api-tls
namespace: production
type: kubernetes.io/tls
data:
tls.crt: |
-----BEGIN CERTIFICATE-----
MIIF...
-----END CERTIFICATE-----
tls.key: |
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC...
-----END PRIVATE KEY-----
The deployment manifest mounts this secret into a pod:
spec:
containers:
- name: app
image: mycompany/api:v1.2.0
volumeMounts:
- name: tls-secret
mountPath: /etc/tls
readOnly: true
volumes:
- name: tls-secret
secret:
secretName: api-tls
For non-Kubernetes environments, systemd services use a Certificate section in the unit file:
[Unit]
Description=API Service
[Service]
ExecStart=/app/api-server
Environment=TLS_CERT_FILE=/etc/tls/tls.crt
Environment=TLS_KEY_FILE=/etc/tls/tls.key
Certificates=api-tls
[Install]
WantedBy=multi-user.target
[Certificate]
Source=secret:/etc/tls/tls.crt
Key=secret:/etc/tls/tls.key
The service starts only after loading the certificate; if the file is missing or invalid, the systemd unit logs Failed to load certificate.
Renewal is triggered by monitoring certificate expiry. A script checks the notAfter field in the PEM certificate:
#!/bin/bash
CERT_FILE="/etc/tls/tls.crt"
DAYS_THRESHOLD=30
not_after=$(openssl x509 -in "$CERT_FILE" -noout -enddate | cut -d= -f2)
expiry_date=$(date -d "$not_after" "+%Y-%m-%d")
today=$(date "+%Y-%m-%d")
days_until_expiry=$(( ($(date -d "$expiry_date" +%s) - $(date -d "$today" +%s)) / 86400 ))
if [ "$days_until_expiry" -lt "$DAYS_THRESHOLD" ]; then
echo "Renewing certificate: $cert_file expires in $days_until_expiry days"
# trigger renewal via API
curl -X POST \
-H "Content-Type: application/json" \
-d '{"reason": "expiry-reminder"}' \
https://ca.mycompany.com/api/v1/certificates/renewals
fi
Renewal is initiated by creating a new request at the CA, often using the same CSR or a new one:
POST /api/v1/certificates/renewals HTTP/1.1
Host: ca.mycompany.com
Content-Type: application/json
{
"certificateId": "12345",
"reason": "expiry-reminder"
}
The CA returns a 202 Accepted with a Location header to the renewal job:
HTTP/1.1 202 Accepted
Location: /api/v1/certificates/renewals/67890
Content-Type: application/json
{
"id": "67890",
"status": "pending",
"certificateId": "12345",
"renewalAt": "2024-03-15T12:00:00Z"
}
The renewal process may involve a challenge (e.g., DNS-01, HTTP-01) for domain validation. The CA updates the certificate, and the client updates the deployed secret or file.
Rotation replaces the current certificate with a new one without downtime. The service loads the new certificate into memory and begins serving with it, then switches the active certificate after a grace period.
A common pattern uses two secrets: api-tls-current and api-tls-next. During rotation:
api-tls-next is populated with the new certificate.api-tls-next and validates it.api-tls-next as the active TLS configuration.api-tls-current is marked for retirement.In Kubernetes, this is orchestrated via a Deployment with readinessProbe and livenessProbe:
spec:
template:
spec:
containers:
- name: app
image: mycompany/api:v1.2.0
readinessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 3
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 3
env:
- name: TLS_CERT_FILE
value: /etc/tls/tls.crt
- name: TLS_KEY_FILE
value: /etc/tls/tls.key
volumeMounts:
- name: tls-secret
mountPath: /etc/tls
readOnly: true
volumes:
- name: tls-secret
secret:
secretName: api-tls-next
When the readiness probe passes, the service is added to the load balancer. The old certificate continues to serve, and once the new one is stable, the Deployment rolls out with rollingUpdate, swapping the Secret in the volumeMounts.
Revocation is initiated when a certificate is compromised, expired, or the service is decommissioned.
To revoke a certificate, the CA receives a request with the certificate’s serial number:
POST /api/v1/certificates/revoke HTTP/1.1
Host: ca.mycompany.com
Content-Type: application/json
{
"serialNumber": "1234567890abcdef",
"reason": "keyCompromise",
"expiry": "2024-06-15T12:00:00Z"
}
The CA responds with a 200 OK and updates its Certificate Revocation List (CRL) and Online Certificate Status Protocol (OCSP) responder.
The service updates its CRL and OCSP configuration:
[OCSP]
ResponderURL = https://ocsp.mycompany.com
CacheTTL = 3600
CRLFile = /etc/tls/crl.pem
When a service receives a certificate, it checks its status via OCSP:
openssl ocsp -reqin request.der -respin response.der -CAfile ca.crt -text
If the certificate is revoked, the service logs Certificate revoked: serial=1234567890abcdef, reason=keyCompromise.
Monitoring involves checking certificate validity, expiry, and revocation status across the fleet.
A daily cron job checks all certificates:
#!/bin/bash
# monitor-certificates.sh
for service in $(ls /etc/tls/*.crt); do
cert_file="$service"
service_name=$(basename "$cert_file" .crt)
not_after=$(openssl x509 -in "$cert_file" -noout -enddate | cut -d= -f2)
expiry_date=$(date -d "$not_after" "+%Y-%m-%d")
days_left=$(( ($(date -d "$expiry_date" +%s) - $(date +%s)) / 86400 ))
if [ "$days_left" -le 7 ]; then
echo "CRITICAL: $service_name expires in $days_left days"
# send alert via HTTP
curl -X POST \
-H "Content-Type: application/json" \
-d "{
\"service\": \"$service_name\",
\"days_until_expiry\": $days_left,
\"status\": \"critical\",
\"timestamp\": \"$(date -Iseconds)\"
}" \
http://alerting.mycompany.com/api/v1/alerts
fi
done
The alerting system integrates with Slack, PagerDuty, or email, triggering a response when a certificate is within 7 days of expiry.
alert: certificate_expired, and clients log SSL error: certificate verify failed.Failed to load private key: /etc/tls/tls.key, and systemd shows Failed to start API Service.openssl s_client -connect api.mycompany.com:443 shows Verify return code: 18 (self signed certificate) due to mismatched public key.Secret. Clients continue using the old certificate until the next rollout.Certificate lifecycle management is not just provisioning and renewal—it is the ongoing orchestration of trust, availability, and security across the infrastructure. When it breaks, the system speaks in TLS alerts, OpenSSL errors, and unresponsive services.
This page was rewritten on 12 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.
We use cookies for analytics (Google Analytics) and advertising (Google AdSense) to improve your experience and support free content. Privacy Policy