我正在编写一个使用Retrofit API进行服务器通信的应用程序。为了测试返回日期场景我修改了当前日期的设备日期。作为回应,它给出了以下错误日志:
ExtCertPathValidatorException: Could not validate certificate: Certificate not valid until Tue Jan 06 05:30:00 GMT+05:30 2015 (compared to Thu Nov 13 11:52:59 GMT+05:30 2014)
D/Retrofit(22305): at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:324)
D/Retrofit(22305): at com.squareup.okhttp.Connection.upgradeToTls(Connection.java:241)
D/Retrofit(22305): at com.squareup.okhttp.Connection.connect(Connection.java:158)
D/Retrofit(22305): at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:174)
D/Retrofit(22305): at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:120)
D/Retrofit(22305): at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:131)
D/Retrofit(22305): at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:312)
D/Retrofit(22305): at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:235)
D/Retrofit(22305): at com.squareup.okhttp.Call.getResponse(Call.java:262)
D/Retrofit(22305): at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:219)
D/Retrofit(22305): at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:192)
D/Retrofit(22305): at com.squareup.okhttp.Call.execute(Call.java:79)
D/Retrofit(22305): at com.newrelic.agent.android.instrumentation.okhttp2.CallExtension.execute(CallExtension.java:43)
D/Retrofit(22305): at retrofit.client.OkClient.execute(OkClient.java:53)
D/Retrofit(22305): at com.newrelic.agent.android.instrumentation.retrofit.ClientExtension.execute(ClientExtension.java:42)
D/Retrofit(22305): at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
D/Retrofit(22305): at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
D/Retrofit(22305): at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
D/Retrofit(22305): at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
D/Retrofit(22305): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
D/Retrofit(22305): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
D/Retrofit(22305): at java.lang.Thread.run(Thread.java:818)
作为回应,我将NETWORK作为RetrofitError.getKind()对象。
任何建议如何过滤它。
答案 0 :(得分:0)
从RetrofitError错误开始,使用Throwable获取Throwable exc = error.getCause()然后检查是否(exc!= null&& exc instanceof SSLHandshakeException)。 但我建议你使用证书固定,以避免这个问题。