调用DescribeKey接口查询用户主密钥(CMK)详情。
本文将提供一个示例,为您查询ID为key-hzz630494463ejqjx****
的用户主密钥的详情,包括创建者、创建时间、密钥状态、删除保护状态等信息。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
| 名称 | 类型 | 是否必选 | 示例值 | 描述 | 
| Action | String | 是 | DescribeKey | 要执行的操作。取值:DescribeKey。 | 
| KeyId | String | 是 | key-hzz630494463ejqjx**** | 密钥的ID,也可以指定为密钥别名或密钥资源名称(ARN)。关于别名的详细介绍,请参见管理密钥别名。 说明 访问其他阿里云账号下的密钥时,必须输入密钥ARN。密钥ARN的格式为 acs:kms:${region}:${account}:key/${keyid}。 | 
返回数据
| 名称 | 类型 | 示例值 | 描述 | 
| RequestId | String | f1fdfa9d-bd49-418b-942f-8f3e3ec00a4f | 本次调用请求的ID,是由阿里云为该请求生成的唯一标识符,可用于排查和定位问题。 | 
| KeyMetadata | Object | CMK的元数据。 | |
| DeletionProtection | String | Enabled | 是否开启删除保护,取值: 
 | 
| KeyId | String | key-hzz630494463ejqjx**** | 密钥ID。如果请求中的KeyId参数使用的是密钥别名、密钥ARN,在响应中也会返回密钥ID。 | 
| NextRotationDate | String | 2021-07-06T18:22:03Z | 下一次轮转的时间。 说明 当AutomaticRotation取值为Enabled或Suspended时,返回该参数。  | 
| KeyState | String | Enabled | CMK的状态。 更多信息,请参见用户主密钥的状态对API调用的影响。 | 
| RotationInterval | String | 31536000s | 密钥自动轮转的周期。 单位:s。 例如:7天的轮转周期为604800s。 说明 当AutomaticRotation取值为Enabled或Suspended时,返回该参数。  | 
| Arn | String | acs:kms:cn-hangzhou:154035569884****:key/key-hzz630494463ejqjx**** | CMK的资源名称(ARN)。 | 
| Creator | String | 154035569884**** | 创建CMK的阿里云账号。 | 
| LastRotationDate | String | 2024-05-20T06:34:21Z | 最近一次轮转的时间(UTC)。如果是新创建的密钥,则为初始密钥版本生成时间。 | 
| DeleteDate | String | 2024-05-26T18:22:03Z | CMK的预计删除时间(UTC)。 更多信息,请参见ScheduleKeyDeletion。 说明 当KeyState取值为PendingDeletion时,返回该参数。 | 
| PrimaryKeyVersion | String | 515e0b0a-624f-45ab-92b5-54f9b551**** | 对称类型CMK当前的主版本标识符。 | 
| Description | String | key description example | CMK的描述。 | 
| KeySpec | String | Aliyun_AES_256 | CMK的类型。 | 
| Origin | String | Aliyun_KMS | CMK的密钥材料来源。 | 
| MaterialExpireTime | String | 2024-07-06T18:22:03Z | 密钥材料的过期时间(UTC)。当该值为空时,表示密钥材料不会过期。 | 
| DeletionProtectionDescription | String | 该密钥正在被XXX服务使用。已为您设置删除保护。 | 删除保护描述。 | 
| AutomaticRotation | String | Disabled | 是否开启自动轮转,取值: 
 更多信息,请参见自动轮转密钥。 说明 仅对称密钥支持自动轮转。 | 
| ProtectionLevel | String | HSM | CMK的保护级别。 | 
| KeyUsage | String | ENCRYPT/DECRYPT | CMK的用途。 | 
| CreationDate | String | 2024-05-20T06:34:21Z | CMK的创建时间(UTC)。 | 
| DKMSInstanceId | String | kst-bjj62d8f5e0sgtx8h**** | KMS实例的实例ID。 | 
示例
请求示例
http(s)://[Endpoint]/?Action=DescribeKey
&KeyId=key-hzz630494463ejqjx****
&公共请求参数正常返回示例
XML格式
HTTP/1.1 200 OK
Content-Type:application/xml
<DescribeKeyResponse>
    <RequestId>f1fdfa9d-bd49-418b-942f-8f3e3ec00a4f</RequestId>
    <KeyMetadata>
        <DeletionProtection>Enabled</DeletionProtection>
        <KeyId>key-hzz630494463ejqjx****</KeyId>
        <NextRotationDate>2021-07-06T18:22:03Z</NextRotationDate>
        <KeyState>Enabled</KeyState>
        <RotationInterval>31536000s</RotationInterval>
        <Arn>acs:kms:cn-hangzhou:154035569884****:key/key-hzz630494463ejqjx****</Arn>
        <Creator>154035569884****</Creator>
        <LastRotationDate>2024-05-20T06:34:21Z</LastRotationDate>
        <DeleteDate>2024-05-26T18:22:03Z</DeleteDate>
        <PrimaryKeyVersion>515e0b0a-624f-45ab-92b5-54f9b551****</PrimaryKeyVersion>
        <Description>key description example</Description>
        <KeySpec>Aliyun_AES_256</KeySpec>
        <Origin>Aliyun_KMS</Origin>
        <MaterialExpireTime>2024-07-06T18:22:03Z</MaterialExpireTime>
        <DeletionProtectionDescription>该密钥正在被XXX服务使用。已为您设置删除保护。</DeletionProtectionDescription>
        <AutomaticRotation>Disabled</AutomaticRotation>
        <ProtectionLevel>HSM</ProtectionLevel>
        <KeyUsage>ENCRYPT/DECRYPT</KeyUsage>
        <CreationDate>2024-05-20T06:34:21Z</CreationDate>
        <DKMSInstanceId>kst-bjj62d8f5e0sgtx8h****</DKMSInstanceId>
    </KeyMetadata>
</DescribeKeyResponse>JSON格式
HTTP/1.1 200 OK
Content-Type:application/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****"
  }
}错误码
| HttpCode | 错误码 | 错误信息 | 描述 | 
| 400 | InvalidParameter | The specified parameter is not valid. | 参数非法。 | 
| 404 | Forbidden.KeyNotFound | The specified Key is not found. | 指定的密钥不存在。 | 
| 404 | Forbidden.AliasNotFound | The specified Alias is not found. | 指定的别名找不到 | 
访问错误中心查看更多错误码。