#!/usr/bin/env python3 """Local TLS identity/trust exercise. Creates ephemeral certs, no OS trust changes.""" import json from pathlib import Path import shutil import socket import ssl import subprocess import sys import tempfile from concurrent.futures import ThreadPoolExecutor class UnsupportedEnvironment(RuntimeError): """Python, the ssl backend or the certificate command cannot run this lab.""" def check_environment(): """Check everything before any temporary key or certificate is created.""" problems=[] if sys.version_info<(3,10):problems.append(f'Python {sys.version.split()[0]} is below the lab minimum 3.10') if not getattr(ssl,'HAS_TLSv1_3',False):problems.append(f'ssl backend {ssl.OPENSSL_VERSION} lacks TLS 1.3') openssl=shutil.which('openssl') if openssl is None:problems.append('no OpenSSL-compatible command was found') if problems:raise UnsupportedEnvironment('; '.join(problems)+'. Use the L13 offline analysis route.') return openssl def read_exact(conn,count): data=bytearray() while len(data)