Print SSLCertVerificationError if we get one
This also adds an option --verbose, but it doesn't actually do anything. The error is alway reported.
This commit is contained in:
parent
b10b62e77d
commit
2f400fccee
|
@ -11,6 +11,7 @@ import time
|
|||
import requests
|
||||
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--verbose", action="store_true")
|
||||
ap.add_argument("hostname")
|
||||
ap.add_argument("port", type=int, default=443, nargs="?")
|
||||
args = ap.parse_args()
|
||||
|
@ -28,7 +29,8 @@ with socket.create_connection((args.hostname, args.port)) as sock:
|
|||
cert = ssock.getpeercert()
|
||||
not_after = ssl.cert_time_to_seconds(cert["notAfter"])
|
||||
delta = not_after - now
|
||||
except ssl.SSLCertVerificationError:
|
||||
except ssl.SSLCertVerificationError as e:
|
||||
print("got error %s; setting delta to 0", e)
|
||||
delta = 0
|
||||
report0.append({ "measure": "tls_cert_ttl", "unit": "s", "value": delta })
|
||||
|
||||
|
|
Loading…
Reference in New Issue