使用SSL客户端证书的WebView在Android 4 ICS [英] WebView with SSL Client Certificate on Android 4 ICS

查看:680
本文介绍了使用SSL客户端证书的WebView在Android 4 ICS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Android原生的WebView的一个问题。我需要使用SSL客户端证书的站点进行身份验证。而Android的WebView似乎并不支持这一点。作为一种解决方法我用的WebView修改后的版本:

I have a problem with the native WebView on Android. I need to authenticate with a site using a SSL Client Certificate. The Android WebView doesn't seem to support this. As a workaround I used a modified version of the WebView:

<一个href="https://github.com/yonekawa/webview-with-client-certificate">https://github.com/yonekawa/webview-with-client-certificate

修改后的WebView的工作原理是注射正确配置的SSLSocketFactory到标准的Andr​​oid的WebView。这工作正常,在Android 2.x的设备。但是,与Android 4 ICS不工作了。该SSLSocketFactory的是仍然存在的ICS,但它似乎已不再使用。

The modified WebView works by injecting a properly configured SslSocketFactory into the standard Android WebView. This works fine on Android 2.x devices. However, with Android 4 ICS it doesn't work anymore. The SslSocketFactory is still there in ICS, however, it seems that it isn't used anymore.

所以我的问题是:有没有人成功地对ICS配置了Android的WebView,使其适用于客户端证书?或者是有什么替代方案?

So my question is: has anyone succeeded in configuring the Android WebView on ICS so that it works with a client certificate? Or is there any alternative?

我已经尝试过什么:

  • 导入SSL客户端证书导入到Android的密钥库,只是使用的WebView不作任何修改。这不,客户端证书不随请求发送。它的工作原理,在本地浏览器,但。

  • importing the SSL client certificate into the Android keystore and just using the WebView without any modification. This doesn't work, the client certificate is not sent along with the requests. It works in the native browser, though.

创建自己使用的HttpClient,获得网站的HTML,并将其移交到的WebView SSL连接。基本上,这工作,但我需要截取的web视图的所有请求,并处理它们自己。但是,web视图不提供POST请求,这使得这种方法不能用于我的数据。

creating the SSL connection myself using HttpClient, getting the HTML of the site and handing it to the WebView. This basically works, but I need to intercept all requests made by the WebView and handle them myself. However, the WebView doesn't provide the data of POST requests, which makes this approach unusable for me.

推荐答案

我想你想要的是覆盖下面的隐藏方法:

I think what you want is overriding the following hidden method:

public void onReceivedClientCertRequest(WebView view,
ClientCertRequestHandler handler, String host_and_port) {

在默认情况下,这将CANCLE请求。

By default this will cancle the request.

我用这个方法下面这个例子中使用隐藏的API: <一href="http://devmaze.word$p$pss.com/2011/01/19/using-com-android-internal-part-5-summary-and-example/" rel="nofollow">http://devmaze.word$p$pss.com/2011/01/19/using-com-android-internal-part-5-summary-and-example/

I have used this method following this example for using hidden APIs: http://devmaze.wordpress.com/2011/01/19/using-com-android-internal-part-5-summary-and-example/

抱歉这么晚才回答。在你的问题只是stubled ... 希望它仍然会有所帮助。

Sorry for the late answer. Just stubled upon your question... Hope it still helps.

这篇关于使用SSL客户端证书的WebView在Android 4 ICS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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