2016-03-16 15:49:56 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
2016-03-18 20:08:10 +00:00
|
|
|
import datetime, setuptools, ssltools, twitools
|
2016-03-16 15:49:56 +00:00
|
|
|
|
2016-03-30 16:11:49 +00:00
|
|
|
hosts = setuptools.getListSetting("SSL", "hosts")
|
|
|
|
pbefore = int(setuptools.getSetting("SSL", "pbefore"))
|
|
|
|
pafter = int(setuptools.getSetting("SSL", "pafter"))
|
|
|
|
two = twitools.twObject()
|
2016-03-16 15:49:56 +00:00
|
|
|
|
2016-03-30 16:11:49 +00:00
|
|
|
for h in hosts:
|
2016-04-28 21:05:40 +00:00
|
|
|
try:
|
|
|
|
expiry = ssltools.getRemoteExpiry(h[0], h[1])
|
|
|
|
diff = expiry - datetime.datetime.now()
|
|
|
|
if diff < datetime.timedelta(days=pbefore):
|
|
|
|
if expiry > datetime.datetime.now():
|
|
|
|
two.tweet("@%s %s certificate expiring soon (%s). Please renew." % (h[2], h[0], expiry))
|
|
|
|
elif expiry + datetime.timedelta(days=pafter) < datetime.datetime.now():
|
|
|
|
two.tweet("@%s %s certificate has expired! (%s) Please renew ASAP!" % (h[2], h[0], expiry))
|
|
|
|
except:
|
|
|
|
two.tweet("@%s Could not verify SSL certificate on %s:%i. Is the server down?" % (h[2], h[0], h[1]))
|