Report errors as "just expired"
This commit is contained in:
parent
81fa412202
commit
e23f3f8726
|
@ -23,11 +23,14 @@ report0 = []
|
||||||
|
|
||||||
with socket.create_connection((args.hostname, args.port)) as sock:
|
with socket.create_connection((args.hostname, args.port)) as sock:
|
||||||
context = ssl.create_default_context()
|
context = ssl.create_default_context()
|
||||||
with context.wrap_socket(sock, server_hostname=args.hostname) as ssock:
|
try:
|
||||||
cert = ssock.getpeercert()
|
with context.wrap_socket(sock, server_hostname=args.hostname) as ssock:
|
||||||
not_after = ssl.cert_time_to_seconds(cert["notAfter"])
|
cert = ssock.getpeercert()
|
||||||
delta = not_after - now
|
not_after = ssl.cert_time_to_seconds(cert["notAfter"])
|
||||||
report0.append({ "measure": "tls_cert_ttl", "unit": "s", "value": delta })
|
delta = not_after - now
|
||||||
|
except ssl.SSLCertVerificationError:
|
||||||
|
delta = 0
|
||||||
|
report0.append({ "measure": "tls_cert_ttl", "unit": "s", "value": delta })
|
||||||
|
|
||||||
report = [
|
report = [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue