

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Ekspor kunci asimetris dengan CloudHSM CLI
<a name="cloudhsm_cli-key-generate-file"></a>

Gunakan **key generate-file** perintah di CloudHSM CLI untuk mengekspor kunci asimetris dari modul keamanan perangkat keras (HSM). Jika targetnya adalah kunci pribadi, maka referensi ke kunci pribadi akan diekspor dalam format PEM palsu. Jika targetnya adalah kunci publik, maka byte kunci publik akan diekspor dalam format PEM.

File PEM palsu, yang tidak berisi materi kunci pribadi yang sebenarnya tetapi merujuk kunci pribadi di HSM, dapat digunakan untuk membuat SSL/TLS pembongkaran dari server web Anda ke. AWS CloudHSM Untuk informasi lebih lanjut, lihat pembongkaran [SSL/TLS](ssl-offload.md).

## Jenis pengguna
<a name="key-generate-file-user-type"></a>

Jenis pengguna berikut dapat menjalankan perintah ini.
+ Pengguna Crypto (CUs)

## Persyaratan
<a name="key-generate-file-requirements"></a>

Untuk menjalankan perintah ini, Anda harus masuk sebagai CU.

## Sintaksis
<a name="key-generate-file-syntax"></a>

```
aws-cloudhsm > help key generate-file
Generate 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')
```

## Contoh
<a name="key-generate-file-examples"></a>

Contoh ini menunjukkan cara menggunakan **key generate-file** untuk menghasilkan file kunci di AWS CloudHSM cluster Anda.

**Example**  

```
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"
  }
}
```

## Pendapat
<a name="key-generate-file-arguments"></a>

**{{<CLUSTER\_ID>}}**  
ID cluster untuk menjalankan operasi ini pada.  
Wajib: Jika beberapa cluster telah [dikonfigurasi](cloudhsm_cli-configs-multi-cluster.md).

**{{<FILTER>}}**  
Referensi kunci (misalnya,`key-reference=0xabc`) atau daftar atribut kunci yang dipisahkan spasi dalam bentuk `attr.KEY_ATTRIBUTE_NAME=KEY_ATTRIBUTE_VALUE` untuk memilih kunci yang cocok untuk dihapus.  
Untuk daftar atribut kunci CloudHSM CLI yang didukung, lihat [Atribut kunci untuk CloudHSM CLI](cloudhsm_cli-key-attributes.md)  
Wajib: Tidak

**{{<ENCODING>}}**  
Menentukan format encoding untuk file kunci  
Wajib: Ya

**{{<PATH>}}**  
Menentukan path file di mana file kunci akan ditulis  
Wajib: Ya

## Menghasilkan referensi kunci KSP (Windows)
<a name="key-generate-ksp-key-reference"></a>

**catatan**  
Fitur ini hanya ada di SDK versi 5.16.0 dan yang lebih baru.

### Prasyarat
<a name="key-generate-ksp-key-reference-requirements"></a>
+ Anda dapat menghasilkan referensi kunci KSP hanya pada platform Windows.
+ Anda harus masuk sebagai pengguna kripto (CU).

### Lokasi berkas
<a name="key-generate-ksp-key-reference-options"></a>

Secara default, AWS CloudHSM menyimpan file yang dihasilkan di: `C:\Users\Default\AppData\Roaming\Microsoft\Crypto\CaviumKSP\GlobalPartition`

Untuk menentukan lokasi yang berbeda, gunakan `--path` parameter.

### Sintaksis
<a name="key-generate-ksp-key-reference-syntax"></a>

```
aws-cloudhsm > help key generate-file --encoding ksp-key-reference 
Generate 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')
```

### Contoh - Menghasilkan referensi kunci KSP menggunakan filter atribut dari kunci pribadi
<a name="key-generate-ksp-key-reference-example1"></a>

Contoh berikut menghasilkan referensi kunci KSP untuk kunci pribadi dengan label tertentu.

**Example**  

```
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"
  }
}
```

### Contoh - Menghasilkan referensi kunci KSP untuk semua pasangan kunci
<a name="key-generate-ksp-key-reference-example2"></a>

Contoh berikut menghasilkan referensi kunci KSP untuk semua pasangan kunci di cluster Anda.

**Example**  

```
aws-cloudhsm > key generate-file --encoding ksp-key-reference --all
{
  "error_code": 0,
  "data": {
    "message": "Successfully generated key file"
  }
}
```

## Topik terkait
<a name="key-generate-file-seealso"></a>
+ [Atribut kunci untuk CloudHSM CLI](cloudhsm_cli-key-attributes.md)
+ [Tombol filter menggunakan CloudHSM CLI](manage-keys-cloudhsm-cli-filtering.md)
+ [generate-asymmetric-pairKategori di CloudHSM CLI](cloudhsm_cli-key-generate-asymmetric-pair.md)
+ [Kategori generate-simetris di CloudHSM CLI](cloudhsm_cli-key-generate-symmetric.md)