3

I'm using OkHttp 3.4.0-RC1. I'm trying to write a web service that connects an Android 4.2.2 / API 17 device via TLSv1.2. I saw the answer at the bottom of this post Android Enable TLSv1.2 in OKHttp but apparently the method setSslSocketFactory is no longer present. I also did not see anything in the Https doc on OKHttp. Thanks!

Community
  • 1
  • 1
Flatpick13
  • 61
  • 1
  • 7

1 Answers1

8

The SslSocketFactory is now configured on the OkHttpClient.Builder

client = new OkHttpClient.Builder()
    .sslSocketFactory(sslSocketFactory, trustManager)
    .build();

https://github.com/square/okhttp/blob/3f7a3344a4c85aa3bbb879dabac5ee625ab987f3/samples/guide/src/main/java/okhttp3/recipes/CustomTrust.java#L54

Yuri Schimke
  • 12,435
  • 3
  • 35
  • 69
  • Thank you for the clarification! I tried this and it didn't help. It looks like the default protocols are still being used, i.e., when I watch the debugger I still see "TLS1" and "SSLv3" even after I told it to use TLSv1.2. I can understand if this is an old issue by using 4.2.2, I'm just stuck using that API. – Flatpick13 Jul 07 '16 at 18:09
  • Yep, I didn't look into how to enable TLSv1.2, just answering your what happened to setSslSocketFactory question. – Yuri Schimke Jul 07 '16 at 18:12