From b8e8dd8144abd92d1f80e550b8460a03c28405b2 Mon Sep 17 00:00:00 2001 From: Guilhem MARION Date: Mon, 10 Oct 2022 07:22:11 +1030 Subject: [PATCH] Make retcode the number of failed checks --- certo/__main__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/certo/__main__.py b/certo/__main__.py index 854f469..ff20d0e 100644 --- a/certo/__main__.py +++ b/certo/__main__.py @@ -8,7 +8,6 @@ Options: -t SECONDS --timeout=SECONDS Timeout for SSL Handshake [default: 5] """ import logging -from pprint import pprint from docopt import docopt @@ -30,7 +29,11 @@ if __name__ == "__main__": logging.info(f"Getting CERT from {hs}") results.append(check_host_certificate_expiration(hs, days_to_expiration)) + failed = list(r for r in results if not r.check_successful) + if output_as_json: print(json_output(results)) else: print(default_output(results)) + + exit(len(failed))