-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimplesslcheck.py
More file actions
47 lines (43 loc) · 1.59 KB
/
Copy pathSimplesslcheck.py
File metadata and controls
47 lines (43 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import OpenSSL
import ssl
import socket
from datetime import date
import datetime
import sys
class Simplesslcheck:
file = "C:/tmp/items.txt"
with open(file, "r") as f:
for line in f:
server = line.split(",")[0]
port = line.split(",")[1]
list_adr = (server, port.strip())
try:
cert = ssl.get_server_certificate(list_adr)
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, cert)
data = x509.get_notAfter()
index = 0
year = day = ""
month = ""
# Get year
while index <= 3:
year += data[index]
index += 1
# Get month
counter = index + 1
while index <= counter:
month += data[index]
index += 1
# Get day
counter += 2
while index <= counter:
day += data[index]
index += 1
# print year, month, day
now = datetime.datetime.now()
date_now = date(now.year, now.month, now.day)
date_cer = date(int(year), int(month), int(day))
print "Days left:",(date_cer - date_now).days
cnt += 1
except socket.gaierror:
print sys.exc_info()
pass