TROUBLESHOOTING
Diagnose certificate hostname and SNI mismatches
Trace three separate steps: DNS chooses an address, SNI selects a virtual host and hostname verification checks the certificate against the URL.
Find where it fails
A virtual host selects its default certificate, an alias is missing from the SAN extension, or a test connected by IP without the intended SNI hostname.
Record the requested hostname, SNI value and presented SANs. Enable hostname verification in the test and compare the result against each intended destination.
Work through the symptoms
The certificate covers another hosted site
Check the SNI virtual host and default-certificate configuration at the TLS terminator.
The expected site is selected but a SAN is missing
Issue and deploy a certificate covering the intended service identity.
The error appears only in an IP-based test
Keep the hostname as the verification identity and override the destination address instead.
Run the checks
curl -Iv --connect-timeout 10 --max-time 20 \
--resolve 'api.example.com:443:192.0.2.20' https://api.example.com/
openssl s_client -connect 192.0.2.20:443 -servername api.example.com \
-verify_hostname api.example.com -verify_return_error </dev/nullReplace 192.0.2.20 with the server address you want to test. Both commands keep api.example.com as the SNI name and certificate identity.
Apply the fix
Correct the virtual-host/SNI selection or deploy a certificate whose SANs cover the intended name. Verify the hostname against each intended destination; keep the hostname in the URL when overriding the IP.
Confirm the result
Check each public alias against the server that should answer it. Confirm both a matching SAN and a trusted chain.
Check the deployment details
The HTTP Host header arrives after the TLS handshake. To choose and verify a certificate, preserve the hostname in SNI and in the verification options. Test the apex and aliases separately; *.example.com covers one label below example.com.
Keep it monitored
Include hostname validation in post-deployment checks, and track expiry for each public name used by visitors and integrations.