`SSL: no alternative certificate subject name matches target host name 'api.example.com'`
BeginnerTroubleshootingTLS and certificate errors
Answer
Likely causes → The certificate's SAN list doesn't include the hostname used, you connected by IP, or the server returned its default certificate because SNI didn't match any vhost.
Diagnose →
echo | openssl s_client -connect api.example.com:443 -servername api.example.com 2>/dev/null \
| openssl x509 -noout -ext subjectAltName
Fix → Issue a certificate that includes the name (wildcards cover one label only: *.example.com doesn't match a.b.example.com), or fix the vhost so it serves the right certificate.
Prevent → Generate SANs from the same config that defines hostnames.
More on TLS and certificate errors
`curl: (60) SSL certificate problem: certificate has expired`Beginner`curl: (60) SSL certificate problem: unable to get local issuer certificate`BeginnerSome clients get the wrong certificate (another site's) from a shared IP.Intermediate`SSL routines::sslv3 alert handshake failure` from `openssl` or curl.IntermediatePython `requests` fails with `SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain`.BeginnerNode.js app logs `Error: unable to verify the first certificate` calling an internal API.Intermediate