KeyChain.ChooseX509Certificate2WithPrivateKeyAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| ChooseX509Certificate2WithPrivateKeyAsync(Activity, String[], IPrincipal[], Uri, String) |
Displays the system UI for the user to select a certificate, then retrieves the corresponding X509Certificate2 with its private key, filtering by URI. |
| ChooseX509Certificate2WithPrivateKeyAsync(Activity, String[], IPrincipal[], String, Int32, String) |
Displays the system UI for the user to select a certificate, then retrieves the corresponding X509Certificate2 with its private key, filtering by host and port. |
ChooseX509Certificate2WithPrivateKeyAsync(Activity, String[], IPrincipal[], Uri, String)
Displays the system UI for the user to select a certificate, then retrieves the corresponding X509Certificate2 with its private key, filtering by URI.
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 to filter by, or null to allow the user to choose any alias.
- 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 the user cancelled the selection
or the certificate could not be retrieved.
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. This overload requires Android API 23 or later.
Applies to
ChooseX509Certificate2WithPrivateKeyAsync(Activity, String[], IPrincipal[], String, Int32, String)
Displays the system UI for the user to select a certificate, then retrieves the corresponding X509Certificate2 with its private key, filtering by host and port.
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 for no host filtering.
- 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 the user cancelled the selection
or the certificate could not be retrieved.
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.