语言

DevicePolicyManager.SetKeyPairCertificate 方法

定义

重载

名称 说明
SetKeyPairCertificate(ComponentName, String, IList<Certificate>, Boolean)

可通过以下方式调用此 API,将证书与使用#generateKeyPair生成的密钥对相关联,并设置密钥是否可供用户在证书选择提示中选择:<ul><li>Device owner</li><li>Profile owner</li li Delegated certificate installer>/<><li><li>credential management app</li></ul>

SetKeyPairCertificate(String, IList<Certificate>, Boolean, KeyChainManagerKeyPairScope)

将证书链与特定的作用域密钥相关联。

SetKeyPairCertificate(ComponentName, String, IList<Certificate>, Boolean)

可通过以下方式调用此 API,将证书与使用#generateKeyPair生成的密钥对相关联,并设置密钥是否可供用户在证书选择提示中选择:<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

参数

admin
ComponentName

此请求与哪个 DeviceAdminReceiver 请求相关联,或者 null 调用方不是设备管理员。

alias
String

要在其中安装证书的私钥别名。 应 alias 表示现有的私钥。 如果具有该别名的证书已存在,则会覆盖该证书。

certs
IList<Certificate>

要安装的证书链。 该链应以叶证书开头,并按顺序包含信任链。 这将由 android.security.KeyChain#getCertificateChain.

isUserSelectable
Boolean

true 如果指示用户可以通过证书选择提示来选择此密钥, false 则表示只能通过实现 android.app.admin.DeviceAdminReceiver#onChoosePrivateKeyAlias此密钥授予访问权限。

返回

如果提供的 证书存在并且证书已成功关联,则为 ;否则为 />。

特性

注解

可通过以下方式调用此 API,将证书与使用#generateKeyPair生成的密钥对相关联,并设置密钥是否可供用户在证书选择提示中选择:<ul><li>Device owner</li><li>Profile owner</li li Delegated certificate installer>/<><li><li>credential management app</li></ul>

从 Android android.os.Build.VERSION_CODES#S中,凭据管理应用可以调用此 API。 如果凭据管理应用调用,则 componentName 必须为 null。 请注意,在非托管设备上只能有凭据管理应用。

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

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于

SetKeyPairCertificate(String, IList<Certificate>, Boolean, KeyChainManagerKeyPairScope)

将证书链与特定的作用域密钥相关联。

[Android.Runtime.Register("setKeyPairCertificate", "(Ljava/lang/String;Ljava/util/List;ZI)Z", "GetSetKeyPairCertificate_Ljava_lang_String_Ljava_util_List_ZIHandler", ApiSince=37)]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_CERTIFICATES")]
public virtual bool SetKeyPairCertificate(string alias, System.Collections.Generic.IList<Java.Security.Cert.Certificate> certs, bool isUserSelectable, Android.Security.KeyChainManagerKeyPairScope scope);
[<Android.Runtime.Register("setKeyPairCertificate", "(Ljava/lang/String;Ljava/util/List;ZI)Z", "GetSetKeyPairCertificate_Ljava_lang_String_Ljava_util_List_ZIHandler", ApiSince=37)>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_CERTIFICATES")>]
abstract member SetKeyPairCertificate : string * System.Collections.Generic.IList<Java.Security.Cert.Certificate> * bool * Android.Security.KeyChainManagerKeyPairScope -> bool
override this.SetKeyPairCertificate : string * System.Collections.Generic.IList<Java.Security.Cert.Certificate> * bool * Android.Security.KeyChainManagerKeyPairScope -> bool

参数

alias
String

要在其中安装证书的私钥别名。

certs
IList<Certificate>

要安装的证书链。

isUserSelectable
Boolean

true 如果指示用户可以通过证书选择提示来选择此密钥, false 则表示只能通过实现此密钥授予访问权限 android.app.admin.DeviceAdminReceiver#onChoosePrivateKeyAlias 或调用 #grantKeyPairToApp 和 #grantKeyPairToWifiAuth。

scope
KeyChainManagerKeyPairScope

键对的范围: KeyChainManager#KEYPAIR_SCOPE_USER 或 KeyChainManager#KEYPAIR_SCOPE_DEVICE。

返回

如果证书已成功关联,则为 ;否则为 />。

特性

注解

将证书链与特定的作用域密钥相关联。

此方法扩展 setKeyPairCertificate(ComponentName、String、List、boolean),添加范围参数以确定证书是否应与用户特定密钥链或设备范围的密钥链中的密钥对相关联。

此重载中的密钥差异:使用 KeyChainManager.KEYPAIR_SCOPE_DEVICE:证书将与设备范围的密钥链中的密钥对相关联。 调用方必须在关联用户中运行才能管理设备密钥。 请参阅 isAffiliatedUser()。 不允许凭据管理应用使用此范围;使用 KeyChainManager.KEYPAIR_SCOPE_USER:证书将与调用用户自己的密钥链中的密钥对相关联。

Android 参考。android.app.admin.DevicePolicyManager.setKeyPairCertificate

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于