slashmark-ssl-check 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ Metadata-Version: 2.4
2
+ Name: slashmark-ssl-check
3
+ Version: 1.0.0
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,12 @@
1
+ from setuptools import setup
2
+
3
+ setup(
4
+ name="slashmark-ssl-check",
5
+ version="1.0.0",
6
+ py_modules=["sm_ssl_check"],
7
+ entry_points={
8
+ "console_scripts": [
9
+ "sm-ssl=sm_ssl_check:main",
10
+ ],
11
+ },
12
+ )
@@ -0,0 +1,3 @@
1
+ Metadata-Version: 2.4
2
+ Name: slashmark-ssl-check
3
+ Version: 1.0.0
@@ -0,0 +1,7 @@
1
+ setup.py
2
+ sm_ssl_check.py
3
+ slashmark_ssl_check.egg-info/PKG-INFO
4
+ slashmark_ssl_check.egg-info/SOURCES.txt
5
+ slashmark_ssl_check.egg-info/dependency_links.txt
6
+ slashmark_ssl_check.egg-info/entry_points.txt
7
+ slashmark_ssl_check.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ sm-ssl = sm_ssl_check:main
@@ -0,0 +1,31 @@
1
+ import ssl
2
+ import socket
3
+ import sys
4
+ from datetime import datetime
5
+
6
+ def check_ssl(host):
7
+ try:
8
+ ctx = ssl.create_default_context()
9
+ with socket.create_connection((host, 443)) as sock:
10
+ with ctx.wrap_socket(sock, server_hostname=host) as ssock:
11
+ cert = ssock.getpeercert()
12
+
13
+ expiry = datetime.strptime(cert['notAfter'], "%b %d %H:%M:%S %Y %Z")
14
+ days_left = (expiry - datetime.utcnow()).days
15
+
16
+ print(f"Host: {host}")
17
+ print(f"Expires on: {expiry}")
18
+ print(f"Days left: {days_left}")
19
+
20
+ except Exception:
21
+ print("Error checking SSL")
22
+
23
+ def main():
24
+ if len(sys.argv) < 2:
25
+ print("Usage: sm-ssl <domain>")
26
+ return
27
+
28
+ check_ssl(sys.argv[1])
29
+
30
+ if __name__ == "__main__":
31
+ main()