Language

KeyChainManager.GetPrivateKey(String, KeyChainManagerKeyPairScope) Method

Definition

Returns the private key for the given alias and scope.

[Android.Runtime.Register("getPrivateKey", "(Ljava/lang/String;I)Ljava/security/PrivateKey;", "", ApiSince=37)]
public Java.Security.IPrivateKey? GetPrivateKey(string alias, Android.Security.KeyChainManagerKeyPairScope scope);
[<Android.Runtime.Register("getPrivateKey", "(Ljava/lang/String;I)Ljava/security/PrivateKey;", "", ApiSince=37)>]
member this.GetPrivateKey : string * Android.Security.KeyChainManagerKeyPairScope -> Java.Security.IPrivateKey

Parameters

alias
String

The alias of the desired key pair.

scope
KeyChainManagerKeyPairScope

The scope to search (#KEYPAIR_SCOPE_USER or #KEYPAIR_SCOPE_DEVICE).

Returns

The PrivateKey, or null if no key exists for the given alias/scope or if access to the key is not granted.

Attributes

Remarks

Returns the private key for the given alias and scope. This method may take several seconds to complete, so it should only be called from a worker thread.

Android reference for android.security.KeyChainManager.getPrivateKey.

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