KMS get_public_key() UnsupportedOperationException

问题描述

当我运行以下代码时(KEY_ID 是我从 client.list_keys() 返回的列表中复制并粘贴的 key_id):

import boto3

client = boto3.client("kms")
client.list_keys()
client.get_public_key(KeyId = "KEY_ID")

# I've also tried:
client.get_public_key(KeyId = "KEY_ID",GrantTokens = [])

我收到以下错误:

raise error_class(parsed_response,operation_name)
botocore.errorfactory.UnsupportedOperationException: An error occurred (UnsupportedOperationException) when calling the GetPublicKey operation:

有人知道我在 get_public_key() 方法中缺少哪些参数吗?

解决方法

get_public_key 仅用于 asymmetric 键。这些密钥具有公共私有组件。

AWS 使用的大多数 KMS 密钥都是 symmetric,并且这些密钥没有任何公共组件。相反,您将使用从 generate_data_key 获得的数据键

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...