DescribeKey - 返回指定主密钥(CMK)的相关信息

查询用户主密钥(CMK)详情。

接口说明

RAM 用户或 RAM 角色调用该 OpenAPI 需要被授予的权限策略详情,请参见访问控制

本文将提供一个示例,为您查询 ID 为key-hzz630494463ejqjx**** 的用户主密钥的详情,包括创建者、创建时间、密钥状态、删除保护状态等信息。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

授权信息

当前API暂无授权信息透出。

请求参数

名称类型必填描述示例值
KeyIdstring

密钥的 ID,也可以指定为密钥别名或密钥资源名称(ARN)。关于别名的详细介绍,请参见管理密钥别名

说明 访问其他阿里云账号下的密钥时,必须输入密钥 ARN。密钥 ARN 的格式为acs:kms:${region}:${account}:key/${keyid}
key-hzz630494463ejqjx****

返回参数

名称类型描述示例值
object
RequestIdstring

本次调用请求的 ID,是由阿里云为该请求生成的唯一标识符,可用于排查和定位问题。

f1fdfa9d-bd49-418b-942f-8f3e3ec00a4f
KeyMetadataobject

CMK 的元数据。

DeletionProtectionstring

是否开启删除保护,取值:

  • Enabled:开启删除保护。
  • Disabled:关闭删除保护。
Enabled
KeyIdstring

密钥 ID。如果请求中的 KeyId 参数使用的是密钥别名、密钥 ARN,在响应中也会返回密钥 ID。

key-hzz630494463ejqjx****
NextRotationDatestring

下一次轮转的时间。

说明 当 AutomaticRotation 取值为 Enabled 或 Suspended 时,返回该参数。
2021-07-06T18:22:03Z
KeyStatestring

CMK 的状态。
更多信息,请参见用户主密钥的状态对 API 调用的影响

Enabled
RotationIntervalstring

密钥自动轮转的周期。
单位:s。
例如:7 天的轮转周期为 604800s。

说明 当 AutomaticRotation 取值为 Enabled 或 Suspended 时,返回该参数。
31536000s
Arnstring

CMK 的资源名称(ARN)。

acs:kms:cn-hangzhou:154035569884****:key/key-hzz630494463ejqjx****
Creatorstring

创建 CMK 的阿里云账号。

154035569884****
LastRotationDatestring

最近一次轮转的时间(UTC)。如果是新创建的密钥,则为初始密钥版本生成时间。

2024-05-20T06:34:21Z
DeleteDatestring

CMK 的预计删除时间(UTC)。
更多信息,请参见 ScheduleKeyDeletion

说明 当 KeyState 取值为 PendingDeletion 时,返回该参数。
2024-05-26T18:22:03Z
PrimaryKeyVersionstring

对称类型 CMK 当前的主版本标识符。

515e0b0a-624f-45ab-92b5-54f9b551****
Descriptionstring

CMK 的描述。

key description example
KeySpecstring

CMK 的类型。

Aliyun_AES_256
Originstring

CMK 的密钥材料来源。

Aliyun_KMS
MaterialExpireTimestring

密钥材料的过期时间(UTC)。当该值为空时,表示密钥材料不会过期。

2024-07-06T18:22:03Z
DeletionProtectionDescriptionstring

删除保护描述。

该密钥正在被XXX服务使用。已为您设置删除保护。
AutomaticRotationstring

是否开启自动轮转,取值:

  • Enabled:开启自动轮转。
  • Disabled:关闭自动轮转。
  • Suspended:暂停执行自动轮转。

更多信息,请参见自动轮转密钥

说明 仅对称密钥支持自动轮转。
Disabled
ProtectionLevelstring

CMK 的保护级别。

HSM
KeyUsagestring

CMK 的用途。

ENCRYPT/DECRYPT
CreationDatestring

CMK 的创建时间(UTC)。

2024-05-20T06:34:21Z
DKMSInstanceIdstring

KMS 实例的实例 ID。

kst-bjj62d8f5e0sgtx8h****

示例

正常返回示例

JSON格式

{
  "RequestId": "f1fdfa9d-bd49-418b-942f-8f3e3ec00a4f",
  "KeyMetadata": {
    "DeletionProtection": "Enabled",
    "KeyId": "key-hzz630494463ejqjx****",
    "NextRotationDate": "2021-07-06T18:22:03Z",
    "KeyState": "Enabled",
    "RotationInterval": "31536000s",
    "Arn": "acs:kms:cn-hangzhou:154035569884****:key/key-hzz630494463ejqjx****",
    "Creator": "154035569884****",
    "LastRotationDate": "2024-05-20T06:34:21Z",
    "DeleteDate": "2024-05-26T18:22:03Z",
    "PrimaryKeyVersion": "515e0b0a-624f-45ab-92b5-54f9b551****",
    "Description": "key description example",
    "KeySpec": "Aliyun_AES_256",
    "Origin": "Aliyun_KMS",
    "MaterialExpireTime": "2024-07-06T18:22:03Z",
    "DeletionProtectionDescription": "该密钥正在被XXX服务使用。已为您设置删除保护。",
    "AutomaticRotation": "Disabled",
    "ProtectionLevel": "HSM",
    "KeyUsage": "ENCRYPT/DECRYPT",
    "CreationDate": "2024-05-20T06:34:21Z",
    "DKMSInstanceId": "kst-bjj62d8f5e0sgtx8h****"
  }
}

错误码

HTTP status code错误码错误信息描述
400InvalidParameterThe specified parameter is not valid.参数非法。
404Forbidden.KeyNotFoundThe specified Key is not found.指定的密钥不存在。
404Forbidden.AliasNotFoundThe specified Alias is not found.指定的别名找不到
404InvalidAccessKeyId.NotFoundThe Access Key ID provided does not exist in our records.-

访问错误中心查看更多错误码。