gpt4 book ai didi

android - 使用 Android WebView 连接到带有客户端证书的安全服务器

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:31:07 24 4
gpt4 key购买 nike

WebView 或更具体地说,PhoneGaps CordovaWebView 能否使用客户端证书向服务器进行身份验证?

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

最佳答案

这是不可能的。 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,但我们做不到。不确定谷歌何时会开放此 API,但它在 JellyBean 中不可用。

关于android - 使用 Android WebView 连接到带有客户端证书的安全服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12807742/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com