TLS validation failure — trust, hostname and validity
TLS certificate verification failures may reflect a hostname mismatch, missing/untrusted issuer, expired or not-yet-valid certificate, incorrect clock or policy constraints. Preserve the intended hostname and SNI; inspect the certificate chain and local clock using authorized endpoints only. Correct clock synchronization if time is wrong; deploy the correct certificate and intermediate chain for the name; distribute an approved CA only through the organization's trust process. Never bypass verification with curl -k or disable hostname checks as a fix. Verify the same hostname with the intended trust store and an application-level request. Roll back to the previous valid certificate/configuration if safe and still valid; protect private keys and use planned renewal. Prevent with expiration monitoring and tested renewal. The lab generates a temporary self-signed test certificate and explicitly trusts only that certificate for offline openssl verify. A wrong hostname fails, the correct hostname succeeds. No TLS handshake, external host, system trust-store modification or production keys are involved. Example prerequisites: Linux, Bash, Python 3; OpenSSL with req -noenc, -addext and verify -verify_hostname support. Run as a non-root user in a private temporary working directory. Example scope: native certificate verification. Expected output: hostname mismatch; correct hostname verifies. No system configuration changes.
Formal Syntax & Structure
date -u; openssl verify -CAfile CA.pem -verify_hostname NAME CERT.pemParameters & Attributes
| Name | Type | Description |
|---|---|---|
| CAfile | diagnostic evidence | Explicit private trust input for this exercise. |
| verify_hostname | diagnostic evidence | Expected DNS identity. |
| validity | diagnostic evidence | Certificate validity and system clock. |
Return Value
Expected normalized laboratory result: hostname mismatch; correct hostname verifies. A passing fixture does not prove that a live incident has the same cause.
Working Example
python3 - <<'PY'import subprocess,tempfilefrom pathlib import Pathwith tempfile.TemporaryDirectory() as d: def run(args): return subprocess.run(['openssl',*args],cwd=d,capture_output=True,text=True,timeout=8) made=run(['req','-x509','-newkey','ec','-pkeyopt','ec_paramgen_curve:prime256v1','-noenc','-days','1','-subj','/CN=demo.invalid','-addext','subjectAltName=DNS:demo.invalid','-keyout','key.pem','-out','cert.pem']) assert made.returncode==0,made.stderr base=['verify','-CAfile','cert.pem','-verify_hostname'] bad=run(base+['wrong.invalid','cert.pem']) assert bad.returncode!=0 and 'hostname mismatch' in bad.stderr,bad.stderr good=run(base+['demo.invalid','cert.pem']) assert good.returncode==0 and good.stdout.strip()=='cert.pem: OK',good.stderrprint('hostname mismatch; correct hostname verifies')PY