使用 Android WebViewClient 启用特定的 SSL 协议 [英] Enabling specific SSL protocols with Android WebViewClient

查看:39
本文介绍了使用 Android WebViewClient 启用特定的 SSL 协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用 WebViewClient 与服务器建立 SSL 连接.服务器配置为仅接受 TLSv1.1 及以上协议.

My application uses WebViewClient to make SSL connections to the server. The server is configured to only accept TLSv1.1 and above protocols.

  1. 在设备上使用 Android WebViewClient 时,如何检查 a) 支持哪些 SSL 协议和 b) 默认启用.
  2. 如何为我的应用程序中使用的 Android WebViewClient 实例启用特定的 SSL 协议.
  1. How do I check which SSL protocols are a) Supported and b) Enabled by default when using Android WebViewClient on a device.
  2. How do I enable specific SSL protocols for Android WebViewClient instance used in my application.

在运行 Android 4.3 的其中一台测试设备上,WebViewClient 抛出带有以下描述的 onReceivedError 回调:

On one of the test devices running Android 4.3, WebViewClient throws onReceivedError callback with the following description:

无法执行 SSL 握手"

"Failed to perform SSL handshake"

Chrome 日志如下:

Chrome logs are as follows:

01-29 15:58:00.073 5486 5525 W chromium_net: external/chromium/net/http/http_stream_factory_impl_job.cc:865: [0129/155800:WARNING:http_stream_factory_impl_job.cc(865)] Falling back to SSLv3 because host is TLS intolerant: 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:ERROR:ssl_client_socket_openssl.cc(792)] handshake failed; returned 0, SSL error code 5, net_error -107 

我的应用程序还使用 HttpClientHttpsUrlConnection 类来设置 SSL 连接.在使用这些类时,我能够使用 SSLSocket API 来启用特定协议.http:///developer.android.com/reference/javax/net/ssl/SSLSocket.html#setEnabledProtocols(java.lang.String[])

My application also uses HttpClient and HttpsUrlConnection classes to setup SSL Connections. I was able to use SSLSocket API to enable specific protocols when using these classes. http://developer.android.com/reference/javax/net/ssl/SSLSocket.html#setEnabledProtocols(java.lang.String[])

我需要对 WebViewClient 做同样的事情.

I need to do the same with WebViewClient.

推荐答案

根据文档,Android 中的 WebView 中不可能支持 TLS 1.0 <4.3.对于 Android 4.4,默认情况下是禁用的.

As per documenation it is NOT possible to support TLS 1.0 in WebView in Android < 4.3. For Android 4.4 it is disabled by default.

查看此图表以了解不同浏览器对 TLS 1.0 的支持:https://en.wikipedia.org/wiki/Transport_Layer_Security#Web_browsers

Check this chart for support of TLS 1.0 in different browsers: https://en.wikipedia.org/wiki/Transport_Layer_Security#Web_browsers

这篇关于使用 Android WebViewClient 启用特定的 SSL 协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆