From dd39b24277703c30de7b2e07fcefe5a88c1ea924 Mon Sep 17 00:00:00 2001 From: Alex Kelly Date: Fri, 1 Oct 2021 10:05:12 -0400 Subject: [PATCH] feat: add option to get host names from an external file --- checkcert/checkcert.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/checkcert/checkcert.py b/checkcert/checkcert.py index 9fc4d9c..b3ba9e1 100644 --- a/checkcert/checkcert.py +++ b/checkcert/checkcert.py @@ -87,12 +87,24 @@ def get_issuer(cert): default=True, help="Enable/disable ANSI color output to show cert validity", ) +@click.option( + "--filename", + "-f", + type=click.Path(), + help="Read a list of hosts to check from a file", +) @click.argument("hosts", nargs=-1) -def main(san, dump, color, hosts): +def main(san, dump, color, filename, hosts): """Return information about certificates given including their validity""" # setup the list of tuples all_hosts = [] # handle a domain given with a : in it to specify the port + if filename: + hosts = [] + with open(filename, "r") as infile: + for line in infile: + line = line.strip() + hosts.append(line) for host in hosts: # if a host has a : in it, split on the :, first field will be host # second field will be the port