Skip to content

Certificate Expired

Error message

                x509: certificate has expired or is not yet valid
              

Quick summary

The TLS certificate used by a service has passed its expiration date, and clients refuse to connect.

Why this happens

  • The TLS certificate was not renewed before its expiration date

  • The system clock is incorrect, making a valid certificate appear expired

  • The certificate was installed with the wrong validity period

  • Automated certificate renewal (e.g., cert-manager) is not working

Minimal example

✗ Broken code
# Certificate expired, HTTPS connections fail
curl https://api.example.com
# Error: x509: certificate has expired
✓ Fixed code
# Renew with certbot (Let's Encrypt)
certbot renew
# Or with cert-manager in K8s
kubectl delete certificate api-cert  # cert-manager will recreate

The certificate expired. The fix renews it using certbot (for Let's Encrypt) or cert-manager (for Kubernetes).

How to diagnose

  • Check the certificate expiration: openssl s_client -connect <host>:443

  • Verify the system clock: date — ensure it is correct

  • Check cert-manager status if using it: kubectl get certificates -A

  • View certificate details: echo | openssl s_client -connect <host>:443 2>/dev/null | openssl x509 -noout -dates

How to fix

  • Renew the certificate with your Certificate Authority (e.g., Let's Encrypt)

  • Fix the system clock if it is incorrect: ntpdate or chrony

  • Restart cert-manager if it is not renewing certificates automatically

  • Install the renewed certificate in your web server or Ingress

How to prevent

  • Use cert-manager for automatic certificate renewal in Kubernetes

  • Set up alerts for certificates expiring within 30 days

  • Monitor certificate expiration dates regularly

Related Resources

Related Glossary

← Back to language