#! /usr/bin/env python3 from sslyze import ( Scanner, ServerScanRequest, ServerNetworkLocation, ) from sslyze.errors import ServerHostnameCouldNotBeResolved from sslyze.plugins.scan_commands import ScanCommand from sslyze.scanner.scan_command_attempt import ScanCommandAttempt from memory_profiler import profile @profile def get_scans() -> None: with open("myhosts.txt") as f: myNames = [line.rstrip() for line in f.readlines()] scan_requests = list() for host in myNames: try: scan_requests.append( ServerScanRequest( server_location=ServerNetworkLocation( hostname=host ), scan_commands={ScanCommand.CERTIFICATE_INFO}, ) ) except BaseException as be: print(f"Exception scanning {host} - {str(be)}") scanner = Scanner() scanner.queue_scans(scan_requests) for row in scanner.get_results(): yield row @profile def main(): scan_results = get_scans() for server_scan_result in scan_results: print(f"\n\n****Results for {server_scan_result.server_location.hostname}****") certinfo_attempt = server_scan_result.scan_result.certificate_info print(certinfo_attempt) main()