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

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

问题描述

我在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:

https://github.com/yonekawa/webview-with-client-certificate

修改的WebView通过将正确配置的SslSocketFactory注入标准Android 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创建SSL连接,获取网站的HTML并将其传递给WebView。这基本上工作,但我需要拦截所有的WebView请求,并自己处理。但是,WebView不提供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) {

默认情况下,

By default this will cancle the request.

我使用下面这个方法来使用隐藏的API:
http://devmaze.wordpress.com/2011/01/19/using-com-android-

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/

很抱歉,迟到的答案。只是偶然的你的问题...
希望它仍然有帮助。

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

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

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