Commit 4ac190ef authored by Klaus-Uwe Mitterer's avatar Klaus-Uwe Mitterer

Finalize SSL command implementation

parent 3690c8ec
Pipeline #168 skipped
......@@ -30,7 +30,7 @@ def logger(message, prio=syslog.LOG_INFO, sink=logging):
def listIncluded(host, section):
for i in setuptools.getListSetting("SSL" if section == 0 else "Ports", "hosts"):
if i[0] == host:
if i[0].lower() == host.lower():
return True
return False
......@@ -57,11 +57,21 @@ class TCPHandler(socketserver.StreamRequestHandler):
elif command in ("ssl", "tls"):
try:
if listIncluded(str(content[1]), SSL):
expiry = ssltools.getRemoteExpiry(str(content[1]), int(content[2]))
try:
expiry = ssltools.getRemoteExpiry(str(content[1]), int(content[2]))
except:
expiry = ssltools.getRemoteExpiry(str(content[1]), 443)
if expiry > datetime.datetime.now():
return "OK: %s certificate is valid until %s." % (content[1], expiry)
elif expiry < datetime.datetime.now():
return "AL: %s certificate has expired! (%s) Please renew ASAP!" % (content[1], expiry)
dm = "%s certificate is valid until: %s" % (content[1], expiry)
try:
delta = int(content[3])
except:
delta = 0
if expiry < datetime.datetime.now() + datetime.timedelta(days=delta):
return "AL: %s" % dm
return "OK: %s" % dm
else:
return "AL: %s certificate has expired! Please renew ASAP! - %s" % (content[1], expiry)
else:
return "NM: %s is not being monitored!" % content[1]
except TypeError:
......@@ -76,10 +86,10 @@ class TCPHandler(socketserver.StreamRequestHandler):
return "UA: Not currently implemented."
else:
return "IM: Unknown command %s." % command
# except TypeError:
# return "IM: Invalid values passed to %s." % command
except TypeError:
return "IM: Invalid values passed to %s. Try HELP %s." % (command, command)
except IndexError:
return "IM: Invalid values passed to %s." % command
return "IM: Invalid values passed to %s. Try HELP %s." % (command, command)
def handle(self):
remote = self.client_address[0] + ":" + str(self.client_address[1])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment