1
0
mirror of https://github.com/librenms/librenms-agent.git synced 2024-05-09 09:54:52 +00:00

Fix ssl.SSLCertVerificationError

If the certificate is already expired, the script crash.
Fix #286
This commit is contained in:
Anael Mobilia
2020-04-08 11:40:41 +02:00
committed by GitHub
parent ca631a3afd
commit bb1d61e2d9

View File

@@ -24,12 +24,14 @@ def get_certificate_data(domain, port=443):
# 3 second timeout because Lambda has runtime limitations
conn.settimeout(3.0)
ssl_info = None
try:
conn.connect((domain, port))
error_msg = None
except ConnectionRefusedError as e:
ssl_info = conn.getpeercert()
except (ConnectionRefusedError, ssl.SSLCertVerificationError) as e:
error_msg = e
ssl_info = conn.getpeercert()
return ssl_info, error_msg