Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

What the Handshake Does

Before any page is sent over HTTPS, the client and server run a TLS handshake. The client lists the protocol versions and ciphers it supports and names the site it wants (SNI). The server picks a version and a cipher and sends its certificate chain. The client checks the certificate, and both sides agree on keys. If any step fails, the connection ends with a handshake error. Today this is TLS; "SSL" survives in the name. Background is in what SSL/TLS is.

Common Causes

CauseTypical sign
Version mismatchFails on old clients only
No shared cipherFails at once
Expired certificateVerify error on dates
Wrong certificateName does not match
Missing intermediateFails on some clients
No SNI sentDefault site's certificate
Wrong client clockValid cert looks expired
Client cert requiredFails without one

Test with curl

curl -v https://example.com/ -o /dev/null

The verbose output shows the TLS version tried, the certificate, and the line where the handshake stops. Force a version to see which ones work:

curl -v --tlsv1.2 --tls-max 1.2 https://example.com/ -o /dev/null
curl -v --tlsv1.3 https://example.com/ -o /dev/null

Test with openssl s_client

openssl s_client -connect example.com:443 -servername example.com
openssl s_client -connect example.com:443 -servername example.com -tls1_2
openssl s_client -connect example.com:443 -servername example.com -tls1_3

Current OpenSSL versions send the name from -connect as SNI on their own; passing -servername makes it explicit and is needed when you connect to an IP address, so the server returns the certificate for that site and not its default one. A successful handshake prints the chain, the negotiated protocol and cipher, and a verify return code of 0. A failed one ends with an error line, often naming a TLS alert such as handshake failure or protocol version, which points to the reason. See openssl s_client.

Certificate Problems

  • Expired: check the dates with openssl x509 -noout -dates -in cert.pem; see NET::ERR_CERT_DATE_INVALID.
  • Missing intermediate: point Nginx at the full chain file, for Let's Encrypt fullchain.pem, not the certificate alone.
  • Wrong certificate: a server block or virtual host without the right name serves another site's certificate.

A Wrong Clock on the Client

A client whose date is far off sees a valid certificate as expired or not yet valid. On a Linux client or server, check the time and its synchronization:

timedatectl

Keep it synchronized with chrony.

Server Protocol Settings

In Nginx, the protocols are set in the http or server block:

ssl_protocols TLSv1.2 TLSv1.3;

In Apache, with mod_ssl:

SSLProtocol -all +TLSv1.2 +TLSv1.3

TLS 1.2 and 1.3 serve current clients. A very old client that supports neither cannot connect, and that is usually the right trade-off. Test before reloading with sudo nginx -t or sudo apachectl configtest. The browser's version of this failure is covered in ERR_SSL_VERSION_OR_CIPHER_MISMATCH.

Client Certificates

A server set to require a client certificate, with ssl_verify_client on in Nginx or SSLVerifyClient require in Apache, ends the handshake for clients that send none. Test with one:

curl -v --cert client.pem --key client.key https://example.com/

Behind Cloudflare

When the handshake between Cloudflare and your origin fails, visitors see error 525 instead; the origin checks are the same. See Cloudflare error 525.

Was this answer helpful?
Loading...