question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TLS v1.2 is not working on KitKat.

See original GitHub issue

If one is trying to use a slightly stricter ConnectionSpec than MODERN_TLS by limiting TLS to only v1.2 then OkHttp doesn’t work on Android KitKat. Even though this version of Android does support TLS v1.2 (https://developer.android.com/reference/javax/net/ssl/SSLSocket.html).

Example:

OkHttpClient will fail to establish connection on KitKat using this spec:

 new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
      .tlsVersions(TlsVersion.TLS_1_2)
      .build();

The underlying problem is that ConnectionSpec is checking if SSLSocket.getEnabledProtocols() contains TLS v1.2 before actually calling setEnabledProtocols() with TLS v1.2. Instead it should check if SSLSocket supports TLS v1.2 and then enable this protocol if so.

It looks like replacing getEnabledProtocols() with getSupportedProtocols() in ConnectionSpec.isCompatible() and ConnectionSpec.supportedSpec() can fix it.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
swankjessecommented, Feb 22, 2016

Sadly no action for us to take here. TLS 1.2 is disabled by default on KitKat, and our policy is to use only TLS versions that are enabled by default.

1reaction
faramundcommented, Feb 16, 2016

Same problem. Here is a solution: http://blog.dev-area.net/2015/08/13/android-4-1-enable-tls-1-1-and-tls-1-2/ This is a hard change, but some payment providers require TLSv1.1 or TLS1.2 now or in next months (PCI-DSS regulations about credit cards), so it is important to enable communications also for 4.4 devices (in theory TLSv1.2 should works also on 4.1).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android KitKat does not support TLSv1.2
AWS supports TLS 1.0, 1.1 and 1.2 but we have it locked to TLSv1.2 in our NodeJS server. The app works for new...
Read more >
Working with TLS 1.2 on Android 4.4 and Lower - Ankush Gupta
Forcing TLS 1.2 To Be Enabled​​ OkHttp's default behavior is to use an SSLSocketFactory to create SSLSocket s with default parameters, and select ......
Read more >
Enabling TLSv1.2 support in Android 4.1 and 4.4 devices
From my research it looks like all android devices beyond API level 16 (Jellybean) CAN support TLSv1. 2, however it is not turned...
Read more >
Allow TLS 1.1 for KitKat/Lollipop devices syncing to ...
My devices have Android KitKat 4.4 which only supports older TLS. ... It was working in Avalanche 6.2 but it looks like Avalanche...
Read more >
KitKat and TLSv1.2
TLSv1.2 came out in 2008 but Android didn't get support for it until Android 5 in 2014. Previous releases including Android 4.4 KitKat...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found