离子使用HTTPS

时间:2014-09-24 10:56:32

标签: android https ion

我正在使用Ion但是当我尝试将其与Https一起使用时,它给了我一个例外。

代码:

Ion.with(getApplicationContext())
    .load(mBaseUrl + "Token")
    .setJsonObjectBody(json)
    (...)

例外:

09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ javax.net.ssl.SSLHandshakeException: Handshake failed
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.google.android.gms.org.conscrypt.OpenSSLEngineImpl.unwrap(SourceFile:421)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:383)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.koushikdutta.async.AsyncSSLSocketWrapper$4.onDataAvailable(AsyncSSLSocketWrapper.java:172)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.koushikdutta.async.Util.emitAllData(Util.java:20)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:175)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:766)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:608)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:37)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.koushikdutta.async.AsyncServer$13.run(AsyncServer.java:557)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:282)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:192)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.google.android.gms.org.conscrypt.Platform.checkServerTrusted(SourceFile:158)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.google.android.gms.org.conscrypt.OpenSSLEngineImpl.verifyCertificateChain(SourceFile:629)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake_bio(Native Method)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ at com.google.android.gms.org.conscrypt.OpenSSLEngineImpl.unwrap(SourceFile:411)
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ ... 10 more
09-24 11:53:00.211  17654-17940/com.gfi.connectelu W/System.err﹕ Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

2 个答案:

答案 0 :(得分:1)

最近有一篇关于Ion的报道issue about SSL Handshake

与此同时,您可以查看Ion: add support for self signed certificates

答案 1 :(得分:0)

您正在与证书错误的服务器通信。如果它是自签名证书,您需要在您的ion的http客户端安装它。

java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.