SSL/TLS handshake basics: how a secure connection starts
Learn the main steps in a TLS handshake, how certificates identify a server, and why people still call it an SSL handshake.
Security / Field note
Find common TLS handshake problems with OpenSSL, curl, and DNS checks, then learn what each result can tell you.
A TLS handshake can fail before a website loads. Start by checking the exact hostname, certificate, TLS version, and application protocol. A command-line result is evidence about one client and one connection; it may differ from a browser or another network.
| What you see | What to check |
|---|---|
| The certificate is expired or not yet valid | Check certificate dates and the device clock. |
| The certificate name does not match | Check the requested hostname, SNI, and the certificate names. |
| The certificate is not trusted | Check the full certificate chain and the client trust store. |
| The client and server cannot agree on a TLS version or cipher | Compare the client offer with the server settings. Do not re-enable obsolete protocols as a quick fix. |
| TLS connects but the application protocol is unexpected | Check ALPN, such as h2 or http/1.1. |
| Some clients work and others fail | Compare client versions, trust stores, middleboxes, DNS answers, and server endpoints. |
Revocation checking is not identical in every client. Some clients use OCSP, stapled status, CRLs, or local policy; others may not have current status information. Treat a revocation result as client- and policy-dependent.
Replace example.com with a hostname you are allowed to test. -servername sends SNI so a server that hosts multiple sites can choose the intended certificate.
openssl s_client -connect example.com:443 -servername example.com -showcertsLook for the negotiated protocol, cipher suite, certificate chain, and verification result. A successful chain check does not always mean the command checked the requested hostname. To request hostname verification, add -verify_hostname:
openssl s_client -connect example.com:443 -servername example.com -verify_hostname example.com -showcertsThis command prints the certificate subject, issuer, and validity dates:
openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -dates -subject -issuerCheck notBefore and notAfter. To verify the hostname, use the -verify_hostname option shown above. Do not rely on the certificate subject line alone; modern hostname checks use the Subject Alternative Name (SAN) extension.
BadSSL provides public test hostnames such as expired.badssl.com, wrong.host.badssl.com, and self-signed.badssl.com. Use them only as diagnostic examples and check their current behavior before relying on a specific result.
curl -vI https://wrong.host.badssl.com/
curl -vI https://expired.badssl.com/Use these commands to ask the server for a TLS 1.3 or TLS 1.2 connection:
openssl s_client -connect example.com:443 -servername example.com -tls1_3
openssl s_client -connect example.com:443 -servername example.com -tls1_2If one works and the other does not, check server policy, client support, and any middleboxes in the path. A failure from one command does not by itself identify the cause.
ALPN selects an application protocol inside TLS. This command offers HTTP/2 and HTTP/1.1:
openssl s_client -connect example.com:443 -servername example.com -alpn h2,http/1.1The handshake can succeed while the selected protocol differs from what an application expects. Check the negotiated ALPN in the OpenSSL output.
DNS can send a client to an unexpected endpoint. Compare the answers the client receives:
dig A example.com +short
dig AAAA example.com +shortCAA records publish which certificate authorities are allowed to issue certificates for a domain:
dig CAA example.com +shortHTTPS records can publish service connection hints, including protocol and Encrypted Client Hello configuration when used. Their presence does not replace TLS certificate checks:
dig HTTPS example.com +shortMake one change at a time and repeat the same check. Avoid disabling certificate validation or enabling SSL and obsolete TLS versions to make a test pass.
Why does OpenSSL work but my browser still fail?
The browser may use a different trust store, DNS answer, proxy, TLS policy, or hostname check. Compare the exact hostname and network path.
Does “Verification: OK” prove the hostname is correct?
Not always. Ask OpenSSL to check the name with
-verify_hostname example.com as well as sending the
matching SNI name.
Should I turn off certificate checks to test a service?
No. Use a controlled test certificate or a dedicated diagnostic endpoint. Disabling verification can hide the exact security problem you need to find.
Continue reading
Learn the main steps in a TLS handshake, how certificates identify a server, and why people still call it an SSL handshake.
Learn the TLS 1.3 handshake step by step, read packet captures in Wireshark, inspect OpenSSL output, and troubleshoot common certificate failures.
Reader signal
Your feedback helps shape the next field note and lab.
Views count when this page opens. You can change or remove your vote during this tab session.