WebView with SSL client certificate on Android 4 ICS

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

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

The modified WebView works by injecting the correctly configured SslSocketFactory into the standard Android WebView. This works great on Android 2.x devices. However, with Android 4 ICS, it no longer works. SslSocketFactory still exists in ICS, however it seems like it is no longer in use.

So my question is: has anyone managed to configure Android WebView on ICS so that it works with a client certificate? Or is there an alternative?

What I already tried:

  • import the SSL client certificate into the Android keystore and just use WebView without any changes. This does not work, the client certificate is not sent along with the requests. However, it works in its own browser.

  • creating the SSL connection itself using HttpClient, retrieving an HTML site and submitting it to WebView. This basically works, but I need to intercept all the requests made by WebView and handle them myself. However, WebView does not provide POST request data, which makes this approach unsuitable for me.

+8
android certificate ssl webview
source share
1 answer

I think you want to override the following hidden method:

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

By default, this will trigger a request.

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

Sorry for the late reply. Just stumbled upon your question ... Hope this still helps.

+3
source share

All Articles