bot: Add try for TLSA missing
All checks were successful
Build Docker / Build Docker (push) Successful in 16s

This commit is contained in:
Nathan Woodburn 2023-09-27 18:11:27 +10:00
parent 1b9f4eafc8
commit 2ac733f33d
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

11
bot.py
View File

@ -196,7 +196,11 @@ async def ssl(ctx, domain: str):
message = message + "\n## TLSA Record from webserver:\n`" + tlsa_server + "`\n"
else:
message = message + "\n## Website Certificate:\n:x: No certificate found\n"
message = message + "\n## TLSA Record from webserver:\n:x: No certificate found\n"
try:
# Check for TLSA record
response = resolver.resolve("_443._tcp."+domain, "TLSA")
tlsa_records = []
@ -213,6 +217,10 @@ async def ssl(ctx, domain: str):
else:
message = message + "\n## Result:\n:x: TLSA record does not match certificate\n"
except:
message = message + "\n## TLSA Records from DNS:\n:x: No TLSA record found\n"
message = message + "\n## Result:\n:x: No TLSA record found\n"
# If message is too long, send it in 2 messages
if (len(message) > 2000):
@ -228,9 +236,6 @@ async def ssl(ctx, domain: str):
else:
await ctx.response.send_message(message)
else:
ctx.response.send_message(f"No certificate found for {domain}")
return
# Catch all exceptions
except Exception as e: