Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import ssl | |
| import socket | |
| from datetime import datetime | |
| def check_ssl_expiry(urls): | |
| results = [] | |
| for url in urls.splitlines(): | |
| url = url.strip() | |
| if not url: | |
| continue | |
| try: | |
| hostname = url.replace("https://", "").replace("http://", "").split("/")[0] | |
| context = ssl.create_default_context() | |
| with socket.create_connection((hostname, 443)) as sock: | |
| with context.wrap_socket(sock, server_hostname=hostname) as ssock: | |
| cert = ssock.getpeercert() | |
| expiry_date = datetime.strptime(cert['notAfter'], "%b %d %H:%M:%S %Y %Z") | |
| days_left = (expiry_date - datetime.utcnow()).days | |
| results.append([url, expiry_date.strftime("%Y-%m-%d"), days_left]) | |
| except Exception as e: | |
| results.append([url, "Error", str(e)]) | |
| return results | |
| iface = gr.Interface( | |
| fn=check_ssl_expiry, | |
| inputs=gr.Textbox(lines=10, placeholder="Enter one URL per line"), | |
| outputs=gr.Dataframe(headers=["URL", "Expiry Date", "Days Left"]), | |
| title="SSL Expiry Checker", | |
| description="Enter URLs to check SSL certificate expiry." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() |