Język

KeyChain.ChooseX509Certificate2WithPrivateKeyAsync Method

Definition

Overloads

Name Description
ChooseX509Certificate2WithPrivateKeyAsync(Activity, String[], IPrincipal[], Uri, String)

Requests selection of a certificate, then retrieves the corresponding X509Certificate2 with its private key.

ChooseX509Certificate2WithPrivateKeyAsync(Activity, String[], IPrincipal[], String, Int32, String)

Requests selection of a certificate, then retrieves the corresponding X509Certificate2 with its private key.

ChooseX509Certificate2WithPrivateKeyAsync(Activity, String[], IPrincipal[], Uri, String)

Requests selection of a certificate, then retrieves the corresponding X509Certificate2 with its private key.

public static System.Threading.Tasks.Task<System.Security.Cryptography.X509Certificates.X509Certificate2?> ChooseX509Certificate2WithPrivateKeyAsync(Android.App.Activity activity, string[]? keyTypes, Java.Security.IPrincipal[]? issuers, Android.Net.Uri? uri, string? alias);
static member ChooseX509Certificate2WithPrivateKeyAsync : Android.App.Activity * string[] * Java.Security.IPrincipal[] * Android.Net.Uri * string -> System.Threading.Tasks.Task<System.Security.Cryptography.X509Certificates.X509Certificate2>

Parameters

activity
Activity

The activity to use as the parent for the certificate selection UI.

keyTypes
String[]

The acceptable types of asymmetric keys, or null to allow any type.

issuers
IPrincipal[]

The acceptable certificate issuers for the certificate matching the private key, or null to allow any issuer.

uri
Uri

The URI for which the server requests the certificate, or null if unavailable.

alias
String

The initial alias to preselect if available, or null for no preselection.

Returns

A Task<TResult> representing the asynchronous operation. The result is an X509Certificate2 containing the certificate and private key, or null if no alias is selected or the certificate or private key is unavailable. On Android 6.0 through Android 9 (API levels 23 through 28), an unavailable key can instead fault the task with a KeyChainException.

Remarks

This method combines ChoosePrivateKeyAliasAsync(Activity, String[], IPrincipal[], Uri, String) and GetX509Certificate2WithPrivateKey(Context, String) into a single call for a one-step TLS client certificate workflow. After an alias is selected, the method retrieves the key and certificate on the captured synchronization context when one is present. The retrieval must not run on the main thread. This overload requires Android API 23 or later.

Applies to

ChooseX509Certificate2WithPrivateKeyAsync(Activity, String[], IPrincipal[], String, Int32, String)

Requests selection of a certificate, then retrieves the corresponding X509Certificate2 with its private key.

public static System.Threading.Tasks.Task<System.Security.Cryptography.X509Certificates.X509Certificate2?> ChooseX509Certificate2WithPrivateKeyAsync(Android.App.Activity activity, string[]? keyTypes, Java.Security.IPrincipal[]? issuers, string? host, int port, string? alias);
static member ChooseX509Certificate2WithPrivateKeyAsync : Android.App.Activity * string[] * Java.Security.IPrincipal[] * string * int * string -> System.Threading.Tasks.Task<System.Security.Cryptography.X509Certificates.X509Certificate2>

Parameters

activity
Activity

The activity to use as the parent for the certificate selection UI.

keyTypes
String[]

The acceptable types of asymmetric keys, or null to allow any type.

issuers
IPrincipal[]

The acceptable certificate issuers for the certificate matching the private key, or null to allow any issuer.

host
String

The host name of the server requesting the certificate, or null if unavailable.

port
Int32

The port number of the server requesting the certificate, or -1 if unavailable.

alias
String

The initial alias to preselect if available, or null for no preselection.

Returns

A Task<TResult> representing the asynchronous operation. The result is an X509Certificate2 containing the certificate and private key, or null if no alias is selected or the certificate or private key is unavailable. On Android 4.0 through Android 9 (API levels 14 through 28), an unavailable key can instead fault the task with a KeyChainException.

Remarks

This method combines ChoosePrivateKeyAliasAsync(Activity, String[], IPrincipal[], String, Int32, String) and GetX509Certificate2WithPrivateKey(Context, String) into a single call for a one-step TLS client certificate workflow. After an alias is selected, the method retrieves the key and certificate on the captured synchronization context when one is present. The retrieval must not run on the main thread.

Applies to