Skip to content

Commit

Permalink
specify usage with the different version of OkHttp supported in the R…
Browse files Browse the repository at this point in the history
…EADME
  • Loading branch information
Jordan committed Nov 8, 2017
1 parent 6126dab commit e3348bf
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.md
Expand Up @@ -109,10 +109,20 @@ protected void onCreate(Bundle savedInstanceState) {
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setSSLSocketFactory(TrustKit.getInstance().getSSLSocketFactory(serverHostname));

// OkHttp 3
// OkHttp 2.x
OkHttpClient client =
new OkHttpClient()
.setSSLSocketFactory(TrustKit.getInstance().getSSLSocketFactory(serverHostname));

// OkHttp 3.0.x, 3.1.x and 3.2.x
OkHttpClient client =
new OkHttpClient.Builder()
.sslSocketFactory(TrustKit.getInstance().getSSLSocketFactory(serverHostname))

// OkHttp 3.3.x and higher
OkHttpClient client =
new OkHttpClient().newBuilder()
.sslSocketFactory(TrustKit.getInstance().getSSLSocketFactory(serverHostname),
.sslSocketFactory(TrustKit.getInstance().getSSLSocketFactory(serverHostname),
TrustKit.getInstance().getTrustManager(serverHostname))
.build();
}
Expand Down

0 comments on commit e3348bf

Please sign in to comment.