CloudHSM CLI で非対称キーをエクスポートする
CloudHSM CLI の key generate-file コマンドを使用して、ハードウェアセキュリティモジュール (HSM) から非対称キーをエクスポートします。ターゲットがプライベートキーの場合、プライベートキーへの参照はフェイク PEM 形式でエクスポートされます。ターゲットがパブリックキーの場合、パブリックキーバイトは PEM 形式でエクスポートされます。
フェイク PEM ファイルは、実際のプライベートキーマテリアルを含むわけではなく、HSM のプライベートキーを参照するため、ウェブサーバーから AWS CloudHSM への SSL/TLS オフロードを確立するために使用できます。詳細については、「SSL/TLS オフロード」を参照してください。
ユーザータイプ
このコマンドは、次のタイプのユーザーが実行できます。
-
Crypto User (CU)
要件
このコマンドを実行するには、CU としてログインする必要があります。
Syntax
aws-cloudhsm >help key generate-fileGenerate a key file from a key in the HSM cluster. This command does not export any private key data from the HSM Usage: key generate-file --encoding<ENCODING>--path<PATH>--filter [<FILTER>...] Options: --cluster-id<CLUSTER_ID>Unique Id to choose which of the clusters in the config file to run the operation against. If not provided, will fall back to the value provided when interactive mode was started, or error --encoding<ENCODING>Encoding format for the key file Possible values: - reference-pem: PEM formatted key reference (supports private keys) - pem: PEM format (supports public keys) --path<PATH>Filepath where the key file will be written --filter [<FILTER>...] Key reference (e.g. key-reference=0xabc) or space separated list of key attributes in the form of attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE to select a matching key for file generation -h, --help Print help (see a summary with '-h')
例
この例は、key generate-file を使用して AWS CloudHSM クラスターにキーファイルを生成する方法を示しています。
aws-cloudhsm >key generate-file --encoding reference-pem --path /tmp/ec-private-key.pem --filter attr.label="ec-test-private-key"{ "error_code": 0, "data": { "message": "Successfully generated key file" } }
引数
<CLUSTER_ID>-
このオペレーションを実行するクラスターの ID。
必須: 複数のクラスターが設定されている場合。
<FILTER>-
キーリファレンス (例:
key-reference=0xabc) またはattr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE形式のキー属性のスペース区切りリスト。これに一致するキーを削除対象として選択します。サポートされている CloudHSM CLI キー属性のリストについては、「CloudHSM CLI のキー属性」を参照してください
必須: いいえ
<ENCODING>-
キーファイルのエンコード形式を指定します
必須: はい
<PATH>-
キーファイルが書き込まれるファイルパスを指定します
必須: はい
KSP キー参照を生成します (Windows)
注記
この機能は、SDK バージョン 5.16.0 以降でのみ使用できます。
前提条件
-
KSP キー参照は Windows プラットフォームでのみ生成できます。
-
Crypto User (CU) としてサインインする必要があります。
ファイルの場所
デフォルトでは、AWS CloudHSM は生成されたファイルを C:\Users\Default\AppData\Roaming\Microsoft\Crypto\CaviumKSP\GlobalPartition に保存します。
別の場所を指定するには、--path パラメータを使用します。
Syntax
aws-cloudhsm >help key generate-file --encoding ksp-key-referenceGenerate a key file from a key in the HSM cluster. This command does not export any private key data from the HSM Usage: key generate-file --encoding<ENCODING>--path<PATH>--filter [<FILTER>...] Options: --encoding<ENCODING>Encoding format for the key file Possible values: - reference-pem: PEM formatted key reference (supports private keys) - pem: PEM format (supports public keys) - ksp-key-reference: KSP key reference format --cluster-id<CLUSTER_ID>Unique Id to choose which of the clusters in the config file to run the operation against. If not provided with multiple clusters configured, will error --path<PATH>Directory path where the key file will be written --filter [<FILTER>...] Key reference (e.g. key-reference=0xabc) or space separated list of key attributes in the form of attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE to select a matching key for file generation --all Generate ksp key reference for all available key pairs in HSM -h, --help Print help (see a summary with '-h')
例 – プライベートキーの属性フィルターを使用して KSP キー参照を生成する
次の例では、特定のラベルを持つプライベートキーの KSP キー参照を生成します。
aws-cloudhsm >key generate-file --encoding ksp-key-reference --path --filter attr.label="ec-test-private-key"{ "error_code": 0, "data": { "message": "Successfully generated key file" } }
例 – すべてのキーペアの KSP キー参照を生成する
次の例では、クラスター内のすべてのキーペアの KSP キー参照を生成します。
aws-cloudhsm >key generate-file --encoding ksp-key-reference --all{ "error_code": 0, "data": { "message": "Successfully generated key file" } }