Dela via


WebViewClient.OnReceivedClientCertRequest(WebView, ClientCertRequest) Method

Definition

Notify the host application to handle a SSL client certificate request.

[Android.Runtime.Register("onReceivedClientCertRequest", "(Landroid/webkit/WebView;Landroid/webkit/ClientCertRequest;)V", "GetOnReceivedClientCertRequest_Landroid_webkit_WebView_Landroid_webkit_ClientCertRequest_Handler")]
public virtual void OnReceivedClientCertRequest (Android.Webkit.WebView? view, Android.Webkit.ClientCertRequest? request);
[<Android.Runtime.Register("onReceivedClientCertRequest", "(Landroid/webkit/WebView;Landroid/webkit/ClientCertRequest;)V", "GetOnReceivedClientCertRequest_Landroid_webkit_WebView_Landroid_webkit_ClientCertRequest_Handler")>]
abstract member OnReceivedClientCertRequest : Android.Webkit.WebView * Android.Webkit.ClientCertRequest -> unit
override this.OnReceivedClientCertRequest : Android.Webkit.WebView * Android.Webkit.ClientCertRequest -> unit

Parameters

view
WebView

The WebView that is initiating the callback

request
ClientCertRequest

An instance of a ClientCertRequest

Attributes

Remarks

Notify the host application to handle a SSL client certificate request. The host application is responsible for showing the UI if desired and providing the keys. There are three ways to respond: ClientCertRequest#proceed, ClientCertRequest#cancel, or ClientCertRequest#ignore. Webview stores the response in memory (for the life of the application) if ClientCertRequest#proceed or ClientCertRequest#cancel is called and does not call onReceivedClientCertRequest() again for the same host and port pair. Webview does not store the response if ClientCertRequest#ignore is called. Note that, multiple layers in chromium network stack might be caching the responses, so the behavior for ignore is only a best case effort.

This method is called on the UI thread. During the callback, the connection is suspended.

For most use cases, the application program should implement the android.security.KeyChainAliasCallback interface and pass it to android.security.KeyChain#choosePrivateKeyAlias to start an activity for the user to choose the proper alias. The keychain activity will provide the alias through the callback method in the implemented interface. Next the application should create an async task to call android.security.KeyChain#getPrivateKey to receive the key.

An example implementation of client certificates can be seen at AOSP Browser

The default behavior is to cancel, returning no client certificate.

Java documentation for android.webkit.WebViewClient.onReceivedClientCertRequest(android.webkit.WebView, android.webkit.ClientCertRequest).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to