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:
|
||||
context = ssl.create_default_context()
|
||||
with context.wrap_socket(sock, server_hostname=args.hostname) as ssock:
|
||||
cert = ssock.getpeercert()
|
||||
not_after = ssl.cert_time_to_seconds(cert["notAfter"])
|
||||
delta = not_after - now
|
||||
report0.append({ "measure": "tls_cert_ttl", "unit": "s", "value": delta })
|
||||
try:
|
||||
with context.wrap_socket(sock, server_hostname=args.hostname) as ssock:
|
||||
cert = ssock.getpeercert()
|
||||
not_after = ssl.cert_time_to_seconds(cert["notAfter"])
|
||||
delta = not_after - now
|
||||
except ssl.SSLCertVerificationError:
|
||||
delta = 0
|
||||
report0.append({ "measure": "tls_cert_ttl", "unit": "s", "value": delta })
|
||||
|
||||
report = [
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue