【问题标题】:Volley SSLHandshakeException on pre lollipop devices棒棒糖前设备上的 Volley SSLHandshakeException
【发布时间】:2018-09-01 19:25:55
【问题描述】:

我正在使用 StringRequest 调用 Web 服务。它在运行 Android 5.0 及更高版本的设备上运行良好。此错误仅在运行 4.0 及以上和 5.0 以下的设备上发生。这是我的堆栈跟踪

/Volley: [1] 7.onErrorResponse: Menus Error==>
03-23 02:56:09.201 1981-1981/com.example W/System.err: com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb8d14900: Failure in SSL library, usually a protocol error
03-23 02:56:09.201 1981-1981/com.example W/System.err: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:741 0xa5046d5c:0x00000000)
03-23 02:56:09.211 1981-1981/com.example W/System.err:     at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:177)
03-23 02:56:09.211 1981-1981/com.example W/System.err:     at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:120)
03-23 02:56:09.211 1981-1981/com.example W/System.err:     at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:87)
03-23 02:56:09.211 1981-1981/com.example W/System.err: Caused by: javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb8d14900: Failure in SSL library, usually a protocol error
03-23 02:56:09.211 1981-1981/com.example W/System.err: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:741 0xa5046d5c:0x00000000)
03-23 02:56:09.231 1981-1981/com.example W/System.err:     at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:448)
03-23 02:56:09.231 1981-1981/com.example W/System.err:     at com.android.okhttp.Connection.upgradeToTls(Connection.java:146)
03-23 02:56:09.241 1981-1981/com.example W/System.err:     at com.android.okhttp.Connection.connect(Connection.java:107)
03-23 02:56:09.241 1981-1981/com.example W/System.err:     at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
03-23 02:56:09.241 1981-1981/com.example W/System.err:     at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
03-23 02:56:09.241 1981-1981/com.example W/System.err:     at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
03-23 02:56:09.261 1981-1981/com.example W/System.err:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
03-23 02:56:09.261 1981-1981/com.example W/System.err:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
03-23 02:56:09.261 1981-1981/com.example W/System.err:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:503)
03-23 02:56:09.271 1981-1981/com.example W/System.err:     at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:136)
03-23 02:56:09.271 1981-1981/com.example W/System.err:     at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:99)
03-23 02:56:09.281 1981-1981/com.example W/System.err:     at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:131)
03-23 02:56:09.281 1981-1981/com.example W/System.err:  ... 2 more

PS:我已经尝试过此链接中的解决方案

SSL Exception when using Volley

【问题讨论】:

  • 你检查过你所在的区域是调用http还是https链接?!我有同样的问题,这是因为我正在调用 http Urls 并将基地址更改为 https 它工作正常。
  • @Omid Heshmatinia,我正在使用 https,这在 http 中工作,但是当我将其更改为 https 时发生错误。

标签: android android-volley sslhandshakeexception


【解决方案1】:

这似乎是 Android 中已知的漏洞。

https://developer.android.com/training/articles/security-gms-provider

try {
  ProviderInstaller.installIfNeeded(getContext());
} catch (GooglePlayServicesRepairableException e) {
   e.printStackTrace();
} catch (GooglePlayServicesNotAvailableException e) {
   e.printStackTrace();
}

注意:此解决方案仅在设备具有播放服务应用时才有效

【讨论】:

    猜你喜欢
    • 2016-02-11
    • 1970-01-01
    • 2016-05-19
    • 1970-01-01
    • 2016-08-14
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    相关资源
    最近更新 更多