【问题标题】:Using a Android WebView to connect to secure server with Client Certificate使用 Android WebView 通过客户端证书连接到安全服务器
【发布时间】:2012-10-09 20:14:46
【问题描述】:

WebView 或者更具体地说,PhoneGaps CordovaWebView 可以使用客户端证书对服务器进行身份验证吗?

我了解本机浏览器可以使用客户端证书,但我正在尝试让 PhoneGap Android 应用程序与需要客户端证书才能工作的服务器通信,但看不到如何操作。我尝试了各种我在 google 上看到的方法,但它们不适用于 Android 4.0 或更高版本。任何建议将不胜感激。

【问题讨论】:

  • 我对非常​​相似的东西很感兴趣。我希望 Phonegap 连接到使用我们自己的证书签名的内部安全服务器,因此 Phonegap 应该从我们公司导入 CA 证书。

标签: android cordova webview android-4.0-ice-cream-sandwich client-certificates


【解决方案1】:

这是不可能的。 sdk 中没有回复客户端证书质询所需的代码。如果你在 android sdk 中查看 WebViewClient 的源代码,你会看到这个方法

/**
 * Notify the host application to handle a SSL client certificate
 * request (display the request to the user and ask whether to
 * proceed with a client certificate or not). The host application
 * has to call either handler.cancel() or handler.proceed() as the
 * connection is suspended and waiting for the response. The
 * default behavior is to cancel, returning no client certificate.
 *
 * @param view The WebView that is initiating the callback.
 * @param handler An ClientCertRequestHandler object that will
 *            handle the user's response.
 * @param host_and_port The host and port of the requesting server.
 *
 * @hide
 */
public void onReceivedClientCertRequest(WebView view,
        ClientCertRequestHandler handler, String host_and_port) {
    handler.cancel();
}

你在文档部分看到@hide 了吗?这意味着“不要将其提供给公众”。我们需要能够覆盖此方法并利用 ClientCertRequestHandler,但我们不能。不确定 google 什么时候会打开这个 API,但它在 JellyBean 中不可用。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-08-23
  • 1970-01-01
  • 2023-03-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-28
相关资源
最近更新 更多