How to get Retrofit/OkHttp to support TLSv1.2 only on all phones (Android >= 5)

Viewed 2926

I am using Retrofit for REST API calls in my Android application, and I have chosen to support only Android 5.0 and newer.

Because TLSv1.2 is supported by those Android versions, I set up my server to only use TLSv1.2. When I test on Nexus 5x (Android versions 7.1 and 8.0) and Nexus 5 (Android version 6.0), everything works as expected. However, when I test on Samsung Galaxy S6 Edge, the app is unable to connect to the server unless I enable TLSv1.1.

I know that the S6 Edge supports TLSv1.2 because when I make an HTTPS connection using javax.net.ssl.HttpsURLConnection and manually setting the TLS version to 1.2 (using SSLContext.getInstance("TLSv1.2"), etc.), it works as expected.

I looked through the OkHttp code (that Retrofit uses to actually make the API calls) and I can't find where it chooses what version to use.

Why does only the Samsung device not default to using TLSv1.2 in Retrofit/OkHttp and how can I force it to do so?


NOTE: This question is not asking how to enable TLSv1.2 support in older Android versions, which has been answered many times on StackOverflow. It is just asking why this works by default on some Android 6.0 phones and not others.

0 Answers
Related