我正在尝试解决从我的设备(android 4.4.2)向后端发送数据的问题,但它引发了异常:
307 22408-22468/ru.scapegoats.checkers E/NativeCrypto: ssl=0x648bfce0 cert_verify_callback x509_store_ctx=0x649de940 arg=0x0
06-15 20:43:02.307 22408-22468/ru.scapegoats.checkers E/NativeCrypto: ssl=0x648bfce0 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA
06-15 20:43:02.352 22408-22408/ru.scapegoats.checkers E/dd: why
06-15 20:43:02.352 22408-22408/ru.scapegoats.checkers W/System.err: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
06-15 20:43:02.355 22408-22408/ru.scapegoats.checkers W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:409)
06-15 20:43:02.355 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:302)
06-15 20:43:02.355 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:270)
06-15 20:43:02.355 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:162)
06-15 20:43:02.355 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
06-15 20:43:02.355 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
06-15 20:43:02.355 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
06-15 20:43:02.355 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
06-15 20:43:02.356 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
06-15 20:43:02.356 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
06-15 20:43:02.356 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
06-15 20:43:02.356 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
06-15 20:43:02.356 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
06-15 20:43:02.357 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
06-15 20:43:02.357 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
06-15 20:43:02.357 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
06-15 20:43:02.357 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
06-15 20:43:02.358 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
06-15 20:43:02.358 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:212)
06-15 20:43:02.358 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
06-15 20:43:02.358 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
06-15 20:43:02.358 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
06-15 20:43:02.358 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.RealCall$AsyncCall.execute(RealCall.java:147)
06-15 20:43:02.359 22408-22408/ru.scapegoats.checkers W/System.err: at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
06-15 20:43:02.359 22408-22408/ru.scapegoats.checkers W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
06-15 20:43:02.359 22408-22408/ru.scapegoats.checkers W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
06-15 20:43:02.359 22408-22408/ru.scapegoats.checkers W/System.err: at java.lang.Thread.run(Thread.java:841)
06-15 20:43:02.359 22408-22408/ru.scapegoats.checkers W/System.err: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
06-15 20:43:02.364 22408-22408/ru.scapegoats.checkers W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:282)
06-15 20:43:02.365 22408-22408/ru.scapegoats.checkers W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:202)
06-15 20:43:02.365 22408-22408/ru.scapegoats.checkers W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:611)
06-15 20:43:02.365 22408-22408/ru.scapegoats.checkers W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
06-15 20:43:02.365 22408-22408/ru.scapegoats.checkers W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:405)
06-15 20:43:02.365 22408-22408/ru.scapegoats.checkers W/System.err: ... 26 more
06-15 20:43:02.366 22408-22408/ru.scapegoats.checkers W/System.err: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
06-15 20:43:02.368 22408-22408/ru.scapegoats.checkers W/System.err: ... 31 more
但是当我在模拟器(android 7.0)上运行我的应用程序时,它的工作正常... 我正在使用改装v2请求:
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
CLIENT = new OkHttpClient.Builder()
.addInterceptor(httpLoggingInterceptor)
.build();
gson = new GsonBuilder()
.setLenient()
.create();
return new Retrofit.Builder()
.baseUrl(mysite)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.client(CLIENT).build();