共用方式為


DevicePolicyManager.SetKeyPairCertificate Method

Definition

This API can be called by the following to associate certificates with a key pair that was generated using #generateKeyPair, and set whether the key is available for the user to choose in the certificate selection prompt: <ul> <li>Device owner</li> <li>Profile owner</li> <li>Delegated certificate installer</li> <li>Credential management app</li> </ul>

[Android.Runtime.Register("setKeyPairCertificate", "(Landroid/content/ComponentName;Ljava/lang/String;Ljava/util/List;Z)Z", "GetSetKeyPairCertificate_Landroid_content_ComponentName_Ljava_lang_String_Ljava_util_List_ZHandler", ApiSince=28)]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_CERTIFICATES")]
public virtual bool SetKeyPairCertificate (Android.Content.ComponentName? admin, string alias, System.Collections.Generic.IList<Java.Security.Cert.Certificate> certs, bool isUserSelectable);
[<Android.Runtime.Register("setKeyPairCertificate", "(Landroid/content/ComponentName;Ljava/lang/String;Ljava/util/List;Z)Z", "GetSetKeyPairCertificate_Landroid_content_ComponentName_Ljava_lang_String_Ljava_util_List_ZHandler", ApiSince=28)>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_CERTIFICATES")>]
abstract member SetKeyPairCertificate : Android.Content.ComponentName * string * System.Collections.Generic.IList<Java.Security.Cert.Certificate> * bool -> bool
override this.SetKeyPairCertificate : Android.Content.ComponentName * string * System.Collections.Generic.IList<Java.Security.Cert.Certificate> * bool -> bool

Parameters

admin
ComponentName

Which DeviceAdminReceiver this request is associated with, or null if the caller is not a device admin.

alias
String

The private key alias under which to install the certificate. The alias should denote an existing private key. If a certificate with that alias already exists, it will be overwritten.

certs
IList<Certificate>

The certificate chain to install. The chain should start with the leaf certificate and include the chain of trust in order. This will be returned by android.security.KeyChain#getCertificateChain.

isUserSelectable
Boolean

true to indicate that a user can select this key via the certificate selection prompt, false to indicate that this key can only be granted access by implementing android.app.admin.DeviceAdminReceiver#onChoosePrivateKeyAlias.

Returns

true if the provided alias exists and the certificates has been successfully associated with it, false otherwise.

Attributes

Remarks

This API can be called by the following to associate certificates with a key pair that was generated using #generateKeyPair, and set whether the key is available for the user to choose in the certificate selection prompt: <ul> <li>Device owner</li> <li>Profile owner</li> <li>Delegated certificate installer</li> <li>Credential management app</li> </ul>

From Android android.os.Build.VERSION_CODES#S, the credential management app can call this API. If called by the credential management app, the componentName must be null. Note, there can only be a credential management app on an unmanaged device.

Java documentation for android.app.admin.DevicePolicyManager.setKeyPairCertificate(android.content.ComponentName, java.lang.String, java.util.List<java.security.cert.Certificate>, boolean).

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