2016-03-31 20 views
0

Okhttp 3.0.0-RC1 ile Retrofit 2.0.0-beta3 kullanıyorum ve önemsiz konuya bakıyorum. Ben CertificatePinner ve çağrı OkHttp kullanan ancak bu uygulamanın bir hata olduretrofit okhttpclient CertificatePinner ile

String hostname = "hostname"; 
CertificatePinner certificatePinner = new CertificatePinner.Builder() 
     .add(hostname, "sha1/rNKiM/IsTzTMJ09jpMtPq4qP+Q8=") 
     .add(hostname, "sha1/hL8+j9RH89wlAW7eNDSS1ZlZ8Z8=") 
     .build(); 
OkHttpClient client = new OkHttpClient.Builder().certificatePinner(certificatePinner).build(); 

// This call works 
OkHttpClient client = new OkHttpClient.Builder().certificatePinner(certificatePinner).build(); 
Request request = new Request.Builder() 
    .url("https://" + hostname + "/api/me") 
    .addHeader("Authorization", "Bearer token") 
    .build(); 
okhttp3.Call call = client.newCall(request); 
//execute call returns 200 with response 

// This is not working and throwing SSL Connection Error 
retrofit = new Retrofit.Builder() 
     .baseUrl("https://" + hostname) 
     .addConverterFactory(GsonConverterFactory.create(gson)) 
     .client(client) 
     .build(); 
+0

"Çalışmıyor" ile ne demek istiyorsun? – Robert

+0

@Robert şimdi düzeltildi, yürütme sırasına göre bir hata buldum. Cevabımı aşağıda yazdım – dhaval

cevap

0

Ben Retrofitler örneğinde aynı müşteri kuruyorum rağmen Retrofitler çağrısı ile çalışmıyor ile ben bağlanırken am HTTPS sunucu çalışıyor hangi nedeniyle İstemci aşağıdaki kodun altında oluşturuldu:

ProviderInstaller.installIfNeeded(getApplication()); 

Sipariş şimdi düzeltildi ve kod düzgün çalışıyor.

İlgili konular