“SSLHandshakeException: Handshake failed” on older Android devices

Newer devices connect fine, older ones report SSLHandshakeException: Handshake failed or “protocol version”. Then the server's TLS configuration doesn't match what the Android version can do. After hardening to “TLS 1.3 only”, this hits every device before Android 10.

Typical messages

javax.net.ssl.SSLHandshakeException: Handshake failed
javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0x…:
  Failure in SSL library, usually a protocol error
  … tlsv1 alert protocol version
ERR_SSL_VERSION_OR_CIPHER_MISMATCH   (Chrome)

Not to be confused with Trust anchor for certification path not found or “Chain validation failed”. That is a problem with the certificate or the date, not the handshake, see Trust anchor not found.

What each Android version supports

AndroidTLS 1.2TLS 1.3Note
4.1 to 4.4available, but not enabled by defaultnoapps have to enable TLS 1.2 themselves
5.0 to 9yes, defaultnoECDHE with AES-GCM from 5.0
10 and lateryesyes

Chrome on Android ships its own TLS library. So a site can work in the browser while apps on the same device, which use the system's TLS implementation, fail.

Causes on the server side

Fix

For almost every case, TLS 1.2 plus TLS 1.3 with ECDHE ciphers and AES-GCM or ChaCha20 is the right choice. It covers Android from 5.0 and is secure. The TLS config generator creates it for your server. For nginx, for example:

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305;
ssl_prefer_server_ciphers off;

The SSL check shows whether the server offers TLS 1.2 afterwards. To see what a particular device supports, open the browser TLS test on it. Keep the difference between Chrome and apps in mind.

Android 4.4: on the app side

On Android 4.4 the app has to enable TLS 1.2 itself. With Google Play services the easiest way is ProviderInstaller.installIfNeeded(context), which loads a current security provider. Without Play services the only option is a custom SocketFactory that enables TLS 1.2. Older devices usually also lack ISRG Root X1, see old Android devices and Let's Encrypt.

FAQ

Should I re-enable TLS 1.0 and 1.1?

No. TLS 1.2 is enough for Android from 5.0. Only Android 4.x devices without Play services still need TLS 1.0 and 1.1, and they usually fail on the root anyway.

Why does it work in Chrome on the same device?

Chrome uses its own TLS library with TLS 1.3 and current ciphers. Apps use the system implementation, which depends on the Android version.

Can an ECDSA certificate be the problem?

Rarely. Android has supported ECDSA for a long time. A cipher list that doesn't match the certificate type is the real problem.

Sources and documentation