use*_*467 27 java ssl https android webviewclient
我的应用程序使用WebViewClient与服务器建立SSL连接.服务器配置为仅接受TLSv1.1及更高版本的协议.
1)如何检查哪些SSL协议是a)支持和b)在设备上使用Android WebViewClient时默认启用.
2)如何为我的应用程序中使用的Android WebViewClient实例启用特定的SSL协议.
在其中一个运行Android 4.3的测试设备上,WebViewClient抛出onReceivedError回调,其描述为"无法执行SSL握手"
Chrome日志如下:
01-29 15:58:00.073 5486 5525 W chromium_net:external/chromium/net/http/http_stream_factory_impl_job.cc:865:[0129/155800:警告:http_stream_factory_impl_job.cc(865)]回到SSLv3,因为主机是TLS不容忍的:10.209.126.125:443 01-29 15:58:00.083 5486 5525 E chromium_net:external/chromium/net/socket/ssl_client_socket_openssl.cc:792:[0129/155800:错误:ssl_client_socket_openssl.cc(792)]握手失败; 返回0,SSL错误代码5,net_error -107
我的应用程序还使用HttpClient和HttpsUrlConnection类来设置SSL连接.在使用这些类时,我能够使用SSLSocket API来启用特定协议. http://developer.android.com/reference/javax/net/ssl/SSLSocket.html#setEnabledProtocols(java.lang.String中[])
我需要对WebViewClient做同样的事情.
小智 9
根据文档,在Android <4.3中的WebView中不支持TLS 1.0.对于Android 4.4,默认情况下禁用.
在不同的浏览器中查看此图表以获得对TLS 1.0的支持:https://en.wikipedia.org/wiki/Transport_Layer_Security#Web_browsers
如果您的应用正在使用或您愿意使用 Google Play 服务,您可以通过安装旧手机上的Provider. 它很容易安装,只有一行(加上异常处理等)。如果您还没有 google play 服务,您还需要将其添加到您的 gradle 文件中。 ProviderInstaller包含在-base包装中。
try {
ProviderInstaller.installIfNeeded(this);
} catch (GooglePlayServicesRepairableException e) {
// Fix it
} catch (GooglePlayServicesNotAvailableException e) {
// Skip it
}
Run Code Online (Sandbox Code Playgroud)
有关完整示例,请参阅Google 的“更新您的安全提供程序以防止 SSL 漏洞” 。
| 归档时间: |
|
| 查看次数: |
15862 次 |
| 最近记录: |