Check for expiry SSL certificate with Python
๐ How to Check SSL Certificate Expiry with Python
Ensuring your website’s SSL certificate is valid and up-to-date is crucial for maintaining security and user trust. An expired SSL certificate can cause browsers to flag your site as unsafe, which is not only bad for security but also terrible for business.
In this blog post, I'll show you how to use Python to check the expiry date of an SSL certificate — a useful tool for automating checks or adding to your DevOps monitoring.
๐งฐ What You’ll Need
-
Python 3 installed
-
ssl
andsocket
(built-in Python modules)
๐งช Python Script to Check SSL Certificate Expiry
Here’s a simple script that checks the expiration date of a website's SSL certificate:
๐ Output
If the certificate is valid, you’ll see something like:
If the certificate has already expired or is invalid, you’ll get an error message.
๐จ Automate the Check
You can take this a step further by:
-
Scheduling the script to run daily with cron or Task Scheduler
-
Sending email alerts when expiry is near
-
Checking multiple domains from a list
Here's a simple extension that checks a list of domains:
Comments
Post a Comment