Udostępnij za pośrednictwem


KeyChain.GetCertificateChain(Context, String) Method

Definition

Returns the X509Certificate chain for the requested alias, or null if the alias does not exist or the caller has no permission to access it (see note on exceptions in #getPrivateKey).

[Android.Runtime.Register("getCertificateChain", "(Landroid/content/Context;Ljava/lang/String;)[Ljava/security/cert/X509Certificate;", "")]
public static Java.Security.Cert.X509Certificate[]? GetCertificateChain (Android.Content.Context context, string alias);
[<Android.Runtime.Register("getCertificateChain", "(Landroid/content/Context;Ljava/lang/String;)[Ljava/security/cert/X509Certificate;", "")>]
static member GetCertificateChain : Android.Content.Context * string -> Java.Security.Cert.X509Certificate[]

Parameters

context
Context
alias
String

The alias of the desired certificate chain, typically returned via KeyChainAliasCallback#alias.

Returns

Attributes

Exceptions

if the alias was valid but there was some problem accessing it.

if called from the main thread.

Remarks

Returns the X509Certificate chain for the requested alias, or null if the alias does not exist or the caller has no permission to access it (see note on exceptions in #getPrivateKey).

<strong>Note:</strong> If a certificate chain was explicitly specified when the alias was installed, this method will return that chain. If only the client certificate was specified at the installation time, this method will try to build a certificate chain using all available trust anchors (preinstalled and user-added).

This method may block while waiting for a connection to another process, and must never be called from the main thread.

As Activity and Service contexts are short-lived and can be destroyed at any time from the main thread, it is safer to rely on a long-lived context such as one returned from Context#getApplicationContext().

In case the caller specifies an alias for which it lacks a grant, it must call #choosePrivateKeyAlias again. See #getPrivateKey for more details on coping with this scenario.

Java documentation for android.security.KeyChain.getCertificateChain(android.content.Context, java.lang.String).

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