SSL ERRORS
hostname mismatch: causes and fixes
The certificate failed OpenSSL’s hostname check. Compare its SANs with the requested name and confirm that SNI selects the right virtual host.
What it means
A direct IP test can reach the right machine while selecting the wrong virtual host. Conversely, sending the expected SNI may still return a certificate that lacks the required SAN. Keep connection routing, SNI selection and certificate-name verification as separate facts.
What to check
- Record the intended hostname, destination IP and SNI value.
- Inspect the presented SANs and compare with the exact requested DNS name.
- Repeat using -servername and -verify_hostname with the same intended hostname.
Test the connection
openssl s_client -connect www.example.com:443 -servername www.example.com \
-verify_hostname www.example.com -verify_return_error </dev/nullRun this OpenSSL 3.x example in a POSIX shell. Keep the hostname, peer address and full verification result with the error report.
How to fix it
- Correct virtual-host selection or an unintended DNS destination if it serves the wrong identity.
- Obtain and deploy a certificate that covers the intended DNS name when the SAN list is incomplete.
- Retest aliases independently; a wildcard only covers one label beneath the domain.
Check the fix
The connection must pass the explicit identity and trust checks with the intended hostname. Keep the hostname even when changing the target address to isolate a particular backend.
Details worth checking
Send both -servername and -verify_hostname. The first selects the virtual host; the second checks the certificate’s identity.