datatheorem / TrustKit-Android

Easy SSL pinning validation and reporting for Android.
MIT License
584 stars 87 forks source link

State Minimum OkHttp Version for the Readme Example #22

Closed tomjackman closed 6 years ago

tomjackman commented 6 years ago

The example in the readme does not work with all versions of 3.x of OkHttp.

This is because the deprecated sslSocketFactory function takes 2 parameters in newer versions of OkHttp 3.x, but in older versions of 3.x, it still uses only 1 parameter which won't work.

https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.Builder.html#sslSocketFactory-javax.net.ssl.SSLSocketFactory-

Maybe we can update the example to state the minimum required OkHttp version?

jobot0 commented 6 years ago

We chose to not write examples for OkHttp 3.1.x and 3.2.x because the method with only one parameter was deprecated. However TrustKit is working with these versions, the same way it does for the ones on the 2.x branch and the HttpUrlConnection example with Trustkit.getInstance().getSSLSocketFactory(url) alone.

tomjackman commented 6 years ago

@jobot0 Hi, yes I mean the following, in the code snippet in the readme, can you change. I lost a lot of time trying to get the readme example working with 3.2.0 as the comment just said // OkHttp 3 so i presumed it was all 3.x versions it worked with.

Maybe we can change the readme example from

  // OkHttp 3
  OkHttpClient client =
    ...
    .build();

to

  // OkHttp 3.3.x and Higher
  OkHttpClient client =
    ...
    .build();
jobot0 commented 6 years ago

@TommyJ1994 Oh ok sorry about that. We'll add both ways on the next release to help people managing with older versions.