Prompt
How do I handle certificate rotation in a secrets manager?
Latest observation
Oct 25, 2026
OpenAI APIWeb search: off
Certificate rotation in a secrets manager usually means you need to update the stored certificate and private key before expiry, distribute the new version safely, and make sure applications can reload it without downtime.
A good approach is:
-
Store certs as versioned secrets
- Keep the current certificate, private key, and chain in a secret with versioning enabled.
- Don’t overwrite blindly; create a new version and keep the old one for rollback.
-
Automate renewal
- Use a scheduled job or your PKI/CA automation to request a new certificate before expiration.
- Common trigger: renew when the cert is within 30 days of expiry.
-
Update the secret atomically
- Write the new cert + key + chain together as one version.
- Mark the new version as “current” or use a label/stage like
latest,current, oractive.
-
Notify or reload consumers
- Applications should either:
- fetch the secret on startup and support hot reload, or
- be restarted/rotated by an operator when the secret changes.
- If you use Kubernetes, mount the secret and use a reloader sidecar/operator or rollout restart.
- Applications should either:
-
Avoid breaking connections
- If the certificate is used for TLS, make sure the server supports loading the new cert before dropping the old one.
- For some systems, run both old and new certs in a transition window.
-
Validate before promoting
- Check that the new cert matches the private key.
- Verify the certificate chain, SANs, and intended hostname coverage.
- Test in a staging environment if possible.
-
Keep rollback simple
- Retain the previous version until the new cert is confirmed working.
- If there’s an issue, switch back to the old version quickly.
-
Audit and alert
- Log every rotation event.
- Alert on failed renewal attempts and upcoming expirations.
- Monitor certificate expiry dates continuously.
-
Use least privilege
- Only the rotation job should be able to write updated secrets.
- Applications should usually have read-only access.
Common patterns by platform
-
Vault
- Use PKI secrets engine or dynamic cert issuance.
- Store a reference to the active version or use Vault-issued short-lived certs.
- Use Vault Agent or templating for reloads.
-
AWS Secrets Manager
- Use version labels like
AWSCURRENTandAWSPREVIOUS. - A rotation Lambda can generate or fetch a new cert and update the secret.
- Use version labels like
-
Kubernetes
- Use
Secretobjects plus cert-manager for issuance/renewal. - Roll pods or use file-watcher reloaders to consume new mounted secrets.
- Use
Practical rule of thumb
A safe rotation flow is:
renew → validate → store new version → promote new version → reload consumers → confirm → retire old version
If you want, I can show:
- a Vault-specific, AWS Secrets Manager, or Kubernetes rotation workflow,
- or a sample rotation script/architecture.