Guida di riferimento alla CLI Key Protect

L'ultima versione del plug-in IBM® Key Protect for IBM Cloud® CLI fornisce un modo sicuro ed efficiente per gestire le chiavi nella vostra istanza di Key Protect.

Quando accedi alla CLI di IBM Cloud, ricevi una notifica quando sono disponibili degli aggiornamenti. Assicurati di tenere aggiornata la tua CLI in modo da poter usare i comandi e gli indicatori disponibili per il plugin della CLI Key Protect.

Note

Per installare e configurare il plugin CLI Key Protect, vedi l'argomento su Configurazione della CLI.

L'esempio che mostra come utilizzare region-set evidenzia un passo critico nella configurazione.

Versioni precedenti

Questa documentazione per la versione 0.8 non include comandi obsoleti.

Tutti i comandi obsoleti funzionano nelle versioni 0.4.0 e 0.5.2. Ovvero, la versione 0.5.2 è compatibile con le versioni 0.3.9 e 0.4.0.

Esempi

Tutti i comandi hanno una sezione Example, che mostra come utilizzare il comando nel contesto di un flusso di lavoro.

Gli esempi presuppongono che l'utente abbia openssl e jq installato.

Molti esempi si avvalgono di una variabile di ambiente impostata per la sessione relativa all'ID istanza Key Protect invece del parametro -i. Le variabili impostate in questo modo verranno utilizzate automaticamente dal plug-in dove e quando necessario.

# export the Key Protect instance id in the command line
$ export KP_INSTANCE_ID=<INSTANCE_ID>

Assicurarsi di impostare l'endpoint dell'istanza Key Protect:

export KP_TARGET_ADDR=<KEY_PROTECT_INSTANCE_ENDPOINT>   

Sostituisci <KEY_PROTECT_INSTANCE_ENDPOINT> con l'endpoint corrispondente all'ID della tua istanza. Ad esempio:

export KP_TARGET_ADDR=https://fadedbee-0000-0000-0000-1234567890ab.api.us-south.kms.appdomain.cloud   

È possibile trovare l'endpoint dell'istanza per Key Protect nella console dell'interfaccia utente IBM Cloud per la propria istanza specifica.

Riepilogo comando ibmCloud kp

ibmcloud kp supporta i comandi elencati di seguito.

comando kp import - token

Il comando kp import-token prepara una chiave root per l'importazione sicura.

Sottocomandi per la gestione dei token di importazione
Sottocomando Stato v0.8 Descrizione
create Crea un token di importazione
codifica chiave Crittografa la chiave che importi nel servizio
nonce - codifica Codifica il nonce generato da kp import-token create
show Richiama un token di importazione

comando istanza kp

Il comando kp instance gestisce le politiche per un Istanza Key Protect.

Sottocomandi per la gestione delle chiavi
Sottocomando Stato v0.8 Descrizione
politiche Elenca le normative associate a un'istanza
aggiornamento - politica allowed - network Aggiornare la politica dell'istanza per allowed network
aggiornamento - politica dual - auth - delete Aggiornare la politica dell'istanza per dual auth delete
politica - aggiornamento rotazione Aggiornare la politica dell'istanza per rotation

comando kp key

Il comando kp key gestisce le chiavi individuali.

Sottocomandi per la gestione delle chiavi
Sottocomando Stato v0.8 Descrizione
alias - creare Crea un alias per un riferimento univoco e conveniente a una chiave
annullamento - eliminazione Annullare una richiesta precedentemente pianificata per eliminare una chiave
create Crea una chiave o importa la tua chiave
elimina Elimina una chiave
disabilita Disabilita una chiave
abilita Abilita una chiave
politiche Recupera un elenco di politiche
aggiornamento - politica dual - auth - delete Aggiornare la politica delle chiavi per dual auth delete
politica - aggiornamento rotazione Aggiornare la politica delle chiavi per rotation
ripristino Ripristina una chiave root che era stata precedentemente eliminata
ruotare Ruota una chiave root
pianificazione - eliminazione Autorizzare l'eliminazione di una chiave, con una politica dual - auth - delete
show Richiama una chiave
sincronizzazione Sincronizzare le risorse associate di una chiave
aprire Spacchetta una chiave di crittografia dati
Aggiorna Aggiornare una chiave, trasferendola in un nuovo keyring
versioni Elencare tutte le versioni chiave
mandare a capo Impacchetta una chiave di crittografia dati

comando key - ring kp

Il supporto Key Ring consente la gestione di gruppi di chiavi per le procedure ottimali utilizzando kp key-ring.

Sottocomandi per la gestione dei portachiavi
Sottocomando Stato v0.8 Descrizione
create Crea un keyring all'interno di un'istanza kp
elimina Elimina un keyring all'interno di un'istanza kp

Altri comandi kp

Altri comandi per la gestione Le risorse Key Protect potrebbero supportare le procedure ottimali.

Comandi per la gestione di altre risorse
Comando Stato v0.8 Descrizione
tasti kp Elenca le chiavi disponibili nella tua istanza di Key Protect
portachiavi kp Elenca i keyring associati all'istanza kp
serie di regioni kp Selezionare un endpoint regionale diverso
registrazioni kp Elencare le associazioni tra le chiavi root e altre risorse cloud
kp kmip Creare e gestire adattatori KMIP e risorse associate.
unità crittografica kp Gestire le unità crittografiche
criptounità kp Elenco delle unità crittografiche assegnate a un'istanza

Gli alias chiave possono essere utilizzati come identificativi per i metodi come mostrato negli esempi per creazione chiave, disabilitazione chiave e in qualsiasi punto in cui sia supportato 'ID chiave o alias'.

Visualizzazione della guida

Questi sono esempi di informazioni della guida kp.

  • ibmcloud kp -h
  • ibmcloud kp import-token -h
  • ibmcloud kp key -h
  • ibmcloud kp keys -h

I comandi kp import-token e kp key hanno sottocomandi. Questi esempi mostrano la guida per alcuni sottocomandi.

  • ibmcloud kp import-token create -h
  • ibmcloud kp key delete -h

kp import-token create

Creare un token di importazione che è possibile utilizzare per codificare e importare una chiave root nel Istanza Key Protect. Per impostazione predefinita, il token di importazione scade dopo 10 minuti (600 secondi).

ibmcloud kp import-token create
     -i, --instance-id    INSTANCE_ID
    [-e, --expiration     EXPIRATION_TIME_SECONDS]
    [-m, --max-retrievals MAX_RETRIEVALS]

Esempio

Questo esempio crea un token di importazione. Il token di importazione è composto da un nonce e un public key.

Un nonce è un numero arbitrario che può essere utilizzato una sola volta in una comunicazione crittografica.

# create an import token that expires in 5 minutes and allows 3 retrievals
$ ibmcloud kp import-token create --expiration 300 --max-retrievals 3

Created                         Expires                         Max Retrievals   Remaining Retrievals
2020-05-04 19:12:07 +0000 UTC   2020-05-04 19:17:07 +0000 UTC   3                3

# show the created token
$ ibmcloud kp import-token show

{
    "nonce": "8rf2ldP/zWm1Tjrb",
    "payload":
        "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0t ...<redacted>... QyBLRVktLS0tLQo="
}

Parametri obbligatori

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -e, --expiration

    Specifica un tempo di scadenza (in secondi) per un token di importazione. Questo valore determina il lasso di tempo per cui il token di importazione e la sua chiave pubblica associata rimangono validi per le operazioni.

    Il valore minimo è 300 secondi (5 minuti), mentre quello massimo è 86400 secondi (24 ore). Il valore predefinito è di 600 secondi (10 minuti).

  • -m, --max-retrievals

    Imposta il conteggio di utilizzo per il token di importazione. Questo valore determina il numero di volte per cui il token di importazione può essere richiamato entro il suo tempo di scadenza prima che non sia più accessibile. Il valore predefinito è 1.

kp import - token key - encrypt

Crittografa il materiale della chiave in cui importi Key Protect utilizzando la chiave pubblica associata alla tua istanza Key Protect.

Quindi, fornire la chiave codificata richiamata quando si esegue ibmcloud kp key create per importare la chiave nel servizio.

ibmcloud kp import-token key-encrypt
        -i, --instance-id INSTANCE_ID
        -k, --key         KEY_MATERIAL
        -p, --pubkey      PUBLIC_KEY
       [-a, --hash        HASH_ALGORITHM]

Esempio

Questo esempio codifica un key material utilizzando la chiave pubblica creata da kp import-token create.

# create an import token that expires in 5 minutes and allows 10 retrievals
$ ibmcloud kp import-token create -e 300 -m 10

# create a random, base64-encoded, 32-byte key material
$ KEY_MATERIAL=$(openssl rand -base64 32)

# extract the public key that was created by the "kp import-token create" command
$ PUBLIC_KEY=$(ibmcloud kp import-token show | jq -r '.["payload"]')

# encrypt the key material using the public key
$ ibmcloud kp import-token key-encrypt -k $KEY_MATERIAL -p $PUBLIC_KEY

Encrypted Key
Ela33aTdDiKVUNryLeM/xwUEaKWvzY+u ...<redacted>... Asv7bZxvyZn9KNU=

Parametri obbligatori

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

  • -k, --key

    Il materiale della chiave base64-encoded che memorizzi e gestisci nel servizio.

    -p, --pubkey

    La chiave di crittografia pubblica base64-encoded distribuita da Key Protect. Per creare una nuova chiave pubblica, utilizzare ibmcloud kp import-token create. Per recuperare una chiave pubblica, utilizzare ibmcloud kp import-token show.

Parametri facoltativi

  • -a, --hash

    L'algoritmo hash utilizzato per racchiudere la chiave. Sono supportati SHA1 e SHA256. Il valore predefinito è SHA256. SHA1 è supportato solo da HPCS.

    Questa opzione viene utilizzata per creare una chiave codificata che può essere utilizzata solo in una richiesta con l'API HPCS. Non utilizzare questa opzione per creare chiavi root Key Protect.

    Hyper Protect Crypto Services (HPCS) è un HSM (hardware security module) e servizio di gestione delle chiavi dedicato. HPCS si integra con Key Protect per generare e crittografare le chiavi. Anche la funzione KYOK (Keep Your Own Key) è abilitata da HPC.

Note

Per ulteriori informazioni su HPCS, consultare Introduzione a IBM Cloud Hyper Protect Crypto Services.

kp import - token nonce - encrypt

Crittografare il nonce distribuito da Key Protect con il materiale della chiave che importi nel servizio.

Quindi, fornire i valori IV e nonce codificati richiamati quando si esegue ibmcloud kp key create per importare la chiave.

ibmcloud kp import-token nonce-encrypt
        -i, --instance-id INSTANCE_ID
        -k, --key         KEY_MATERIAL
        -n, --nonce       NONCE
    [-c, --cbc]

Esempio

Questo esempio codifica nonce utilizzando key material.

Un nonce è un numero arbitrario che può essere utilizzato una sola volta in una comunicazione crittografica.

# create an import token that expires in 5 minutes and allows 10 retrievals
$ ibmcloud kp import-token create -e 300 -m 10

# create a random, base64-encoded, 32-byte key material
$ KEY_MATERIAL=$(openssl rand -base64 32)

# extract the nonce that was created by the "kp import-token create" command
$ NONCE=$(ibmcloud kp import-token show | jq -r '.["nonce"]')

# encrypt the nonce
$ ibmcloud kp import-token nonce-encrypt -k $KEY_MATERIAL -n $NONCE

Encrypted Nonce                            IV
mWQad1RHdWoFXFw/D9h8z43t/+0vIZc55VBBQg==   6nvOwUvQdowoD+3v

Parametri obbligatori

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

  • -k, --key

    Il materiale della chiave base64-encoded che memorizzi e gestisci nel servizio.

    -n, --nonce

    Il nonce utilizzato per verificare una richiesta di importare una chiave. Il valore è base64-encoded. Per recuperare un nonce, utilizzare ibmcloud kp import-token show.

Parametri facoltativi

  • -c, --cbc

    Codificare il nonce utilizzando l'algoritmo di codifica AES - CBC. Questo metodo di algoritmo è supportato solo per HPCS. L'algoritmo di codifica predefinito è AES -GCM.

    Questa opzione è utilizzata per generare un nonce codificato che può essere utilizzato solo in una richiesta con l'API HPCS. Non utilizzare questa opzione per creare chiavi root Key Protect.

    Hyper Protect Crypto Services (HPCS) è un HSM (hardware security module) e servizio di gestione delle chiavi dedicato. HPCS si integra con Key Protect per generare e crittografare le chiavi. Anche la funzione KYOK (Keep Your Own Key) è abilitata da HPC.

Note

Per ulteriori informazioni su HPCS, consultare Introduzione a IBM Cloud Hyper Protect Crypto Services.

Importazione kp - presentazione token

Richiama il token di importazione associato a Key Protect .

Il token di importazione contiene una chiave di crittografia pubblica e un nonce. Fornire la chiave pubblica richiamata e nonce come argomenti per ibmcloud kp import-token nonce-encrypt e ibmcloud kp import-token key-encrypt.

ibmcloud kp import-token show
    -i, --instance-id INSTANCE_ID

Esempio

Questo esempio crea un token di importazione e mostra i risultati.

# create an import token that expires in 5 minutes and allows 10 retrievals
$ ibmcloud kp import-token create -e 300 -m 10

# show the created token
$ ibmcloud kp import-token show

{
    "nonce": "8rf2ldP/zWm1Tjrb",
    "payload":
        "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0t ...<redacted>... QyBLRVktLS0tLQo="
}

# extract the nonce that was created by the "kp import-token create" command
$ ibmcloud kp import-token show | jq -r '.["nonce"]'

8rf2ldP/zWm1Tjrb

# extract the public key that was created by the "kp import-token create" command
$ ibmcloud kp import-token show | jq -r '.["payload"]'

LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0t ...<redacted>... QyBLRVktLS0tLQo=

Parametri obbligatori

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

politiche istanza kp

Richiama i dettagli sulle politiche dell'istanza, come allowed networks (public-and-private o private-only), le politiche allowed IP, l'accesso key create import, le metriche e l'eliminazione con doppia autorizzazione (l'eliminazione di una chiave richiede un'autorizzazione da due utenti).

ibmcloud kp instance policies
    [-i, --instance-id     INSTANCE_ID]
    [-p, --allowed-ip]
    [-a, --allowed-network]
    [-d, --dual-auth-delete]
    [-k, --key-create-import-access]
    [-m, --metrics]
    [-o, --output          OUTPUT]
    [-r, --rotation]

Esempio

L'esempio mostra come utilizzare il comando e i risultati. Se il servizio non ha risultati per la query, verrà restituito un array vuoto ([]).

# update the instance policy and set the allowed network to public-and-private
$ ibmcloud kp instance policy-update allowed-network --enable --network-type public-and-private

Updating instance policy...
OK

# list the instance policies
$ ibmcloud kp instance policies

Retrieving policy details for instance: a192d603-0b8d-452f-aac3-f9e1f95e7411...
OK
Created By        user id ...<redacted>...
Creation Date     2020-06-22T16:17:52Z
Last Updated      2020-06-22T16:17:52Z
Updated By        user id ...<redacted>...
Policy Type       allowedNetwork
Enabled           true
Network Allowed   public-and-private

# disable the instance allowed-network policy
$ ibmcloud kp instance policy-update allowed-network --disable

Updating instance policy...
OK

# list the instance policies - the policy exists and it's disabled
$ ibmcloud kp instance policies

Retrieving policy details for instance: a192d603-0b8d-452f-aac3-f9e1f95e7411...
OK
Created By        user id ...<redacted>...
Creation Date     2020-06-22T16:17:52Z
Last Updated      2020-06-22T16:20:08Z
Updated By        user id ...<redacted>...
Policy Type       allowedNetwork
Enabled           false
Network Allowed   public-and-private

# list the instance policies and show the output as JSON
$ ibmcloud kp instance policies --output json

[
  {
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-22T16:17:52Z",
    "lastUpdated": "2020-06-22T16:20:08Z",
    "updatedBy": "user id ...<redacted>...",
    "policy_type": "allowedNetwork",
    "policy_data": { "enabled": false, "attributes": {   "allowed_network": "public-and-private" }
    }
  }
]

Parametri obbligatori

  • -i, --instance-ID

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -p, --allowed-ip

    Mostra la politica dell'istanza per "ip consentito".

  • -a, --allowed-network

    Mostra la politica dell'istanza per "rete consentita".

  • -d, --dual-auth-delete

    Visualizza la politica dell'istanza per dual authorization delete.

  • -k, --key-create-import-access

    Richiama i dettagli della politica di accesso di creazione importazione della chiave dell'istanza.

  • -m, --metrics

    Richiama i dettagli della politica delle metriche dell'istanza.

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

  • -r, --rotation

    Richiama i dettagli della politica di rotazione dell'istanza.

Politica istanza kp - aggiornamento consentito - rete

Aggiornare la politica per una istanza e impostare la rete consentita su public-and-private o private-only.

La politica allowed-network impedisce a un'istanza di ottenere richieste da reti pubbliche o private.

Per le istanze esistenti, la politica di accesso alla rete viene applicata dopo che è stata impostata.

Per ulteriori informazioni, consultare gestione delle politiche di accesso di rete.

ibmcloud kp instance policy-update allowed-network
    -i, --instance-id  INSTANCE_ID
    -d, --disable OR
    -e, --enable
    -t, --network-type NETWORK_TYPE

Esempio

Questo esempio imposta la politica di "rete consentita" su "pubblica e privata".

# update the instance policy and set the allowed network to public-and-private
$ ibmcloud kp instance policy-update allowed-network --enable --network-type public-and-private

Updating instance policy...
OK

# list the instance policies
$ ibmcloud kp instance policies

Retrieving policy details for instance: a192d603-0b8d-452f-aac3-f9e1f95e7411...
OK
Created By        user id ...<redacted>...
Creation Date     2020-06-22T16:17:52Z
Last Updated      2020-06-22T18:17:32Z
Updated By        user id ...<redacted>...
Policy Type       allowedNetwork
Enabled           true
Network Allowed   public-and-private

Parametri obbligatori

  • -d, --disable

  • -e, --enable

    Disabilitare o abilitare la politica di accesso alla rete. È richiesta un'opzione.

  • -i, --instance-ID

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

  • -t, --network-type

    Specificare il tipo di accesso alla rete consentito. Le opzioni sono public-and-private o private-only.

Politica dell'istanza kp - update dual - auth - delete

Utilizzare la politica dual-auth-delete per cancellare in modo sicuro le chiavi di codifica. Quando elimini una chiave, ne distruggi in modo permanente il contenuto e i dati associati. Tutti i dati crittografati dalla chiave diventano inaccessibili.

Per eliminare una chiave soggetta a una politica di doppia autorizzazione è necessaria l'autorizzazione di due utenti.

Per ulteriori informazioni, vedere Utilizzo di criteri di autorizzazione doppi per l'eliminazione delle chiavi.

Note

L'eliminazione della doppia autorizzazione per un'istanza è differente dall'eliminazione della doppia autorizzazione per le chiavi.

Una volta abilitato dual-auth-delete per una chiave, non è possibile disabilitarlo o rimuoverlo. È necessario attendere 7 giorni prima che la politica scada.

L'eliminazione della doppia autorizzazione per un'istanza può essere abilitata o disabilitata in qualsiasi momento.

Se una chiave ha una politica dual-auth-delete, la modifica della politica dell'istanza non modifica alcuna politica chiave esistente.

Quando modifichi la politica dell'istanza, vengono applicate nuove chiavi con la politica dell'istanza.

ibmcloud kp instance policy-update dual-auth-delete
    -i, --instance-id INSTANCE_ID
    -d, --disable OR
    -e, --enable

Esempi

Questi sono esempi di kp instance policy-update dual-auth-delete.

Esempio 1

Questo esempio abilita la politica di eliminazione della doppia autorizzazione.

# enable the instance dual authorization policy
$ ibmcloud kp instance policy-update dual-auth-delete --enable

Updating instance policy...
OK

# list the instance policies
$ ibmcloud kp instance policies --output json

[
  {
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-22T18:45:14Z",
    "lastUpdated": "2020-06-22T18:45:14Z",
    "updatedBy": "user id ...<redacted>...",
    "policy_type": "dualAuthDelete",
    "policy_data": { "enabled": true
    }
  }
]

# disable the instance dual authorization policy
$ ibmcloud kp instance policy-update dual-auth-delete --disable

Updating instance policy...
OK

# list the instance policies
$ ibmcloud kp instance policies --output json

[
  {
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-22T18:45:14Z",
    "lastUpdated": "2020-06-22T18:51:33Z",
    "updatedBy": "user id ...<redacted>...",
    "policy_type": "dualAuthDelete",
    "policy_data": { "enabled": false
    }
  }
]

Esempio 2

Questo esempio abilita la politica di eliminazione doppia autorizzazione e crea una nuova chiave per mostrare come una nuova chiave eredita la politica dell'istanza.

La disabilitazione della politica di autorizzazione doppia per una istanza non modifica la politica per chiavi esistenti. La politica dell'istanza si applica a nuove chiavi create dopo l'aggiornamento della politica.

# enable the instance dual authorization policy
$ ibmcloud kp instance policy-update dual-auth-delete --enable

Updating instance policy...
OK

# create a new key
$ ibmcloud kp key create my-protected-key

Creating key: 'my-protected-key', in instance: 'a192d603-0b8d-452f-aac3-f9e1f95e7411'...
OK
Key ID                                 Key Name
6a8a129b-0cd4-4667-ba57-b355a125a7ca   my-protected-key

# list the policies for the key - dual-auth-delete is
# enabled because the key inherits the instance policy
$ ibmcloud kp key policies 6a8a129b-0cd4-4667-ba57-b355a125a7ca --output json

[
  {
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-22T19:13:00Z",
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:a192d603-0b8d-452f-aac3-f9e1f95e7411:policy:2427dbde-6cff-41eb-8b5a-ff26b038cafc",
    "lastUpdateDate": "2020-06-22T19:13:00Z",
    "updatedBy": "user id ...<redacted>...",
    "dualAuthDelete": { "enabled": true
    }
  }
]

# attempt to delete the key - this fails
$ ibmcloud kp key delete 6a8a129b-0cd4-4667-ba57-b355a125a7ca

Deleting key: 6a8a129b-0cd4-4667-ba57-b355a125a7ca, from instance: a192d603-0b8d-452f-aac3-f9e1f95e7411...
FAILED
kp.Error:
    correlation_id='8ad33eb2-7bbf-4b7a-a02e-221959920342',
    msg='Conflict: 1 prior authorization(s) are required for deletion: Key could not be deleted. Please see "reasons" for more details.',
    reasons='[AUTHORIZATIONS_NOT_MET: Number of authorizations required to delete is not met -
        FOR_MORE_INFO_REFER: https://cloud.ibm.com/apidocs/key-protect]'

# disable the instance dual authorization policy
$ ibmcloud kp instance policy-update dual-auth-delete --disable

Updating instance policy...
OK

# attempt to delete the key - this fails because the key policy
# does not change when the instance policy is updated
$ ibmcloud kp key delete 6a8a129b-0cd4-4667-ba57-b355a125a7ca

Deleting key: 6a8a129b-0cd4-4667-ba57-b355a125a7ca, from instance: a192d603-0b8d-452f-aac3-f9e1f95e7411...
FAILED
kp.Error:
    correlation_id='cbc0d18b-a816-45ab-af6a-b8e18dc3e628',
    msg='Conflict: 1 prior authorization(s) are required for deletion: Key could not be deleted. Please see "reasons" for more details.',
    reasons='[AUTHORIZATIONS_NOT_MET: Number of authorizations required to delete is not met -
    FOR_MORE_INFO_REFER: https://cloud.ibm.com/apidocs/key-protect]'

Parametri obbligatori

  • -d, --disable

  • -e, --enable

    Disabilitare o abilitare la politica di autorizzazione doppia. È richiesta un'opzione.

  • -i, --instance-ID

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

alias chiave kp - crea

Crea un alias per una chiave e visualizza l'output in formato JSON. Gli alias possono essere utilizzati come riferimento nei metodi che accettano una chiave ID. Ogni alias è univoco solo all'interno dell'istanza fornita e non è riservato nel servizio Key Protect. Ogni chiave può avere fino a cinque alias. Non esiste un limite al numero di alias per istanza. La lunghezza dell'alias può essere compresa tra 2 e 90 caratteri, inclusi.

Un alias deve essere alfanumerico e non può contenere spazi o caratteri speciali diversi da '-' o '_'. Inoltre, l'alias non deve essere un UUID versione 4 e non deve essere un nome riservato Key Protect: allowed_ip, key, keys, metadata, policy, policies, registration, registrations, ring, rings, rotate, wrap, unwrap, rewrap, version, versions.

ibmcloud kp key alias-create KEY_ID -a KEY_ALIAS
    -i, --instance-id     INSTANCE_ID
    -a, --alias           KEY_ALIAS
    [-o, --output         OUTPUT]

Esempi

Questo è un esempio di kp key alias-create.

Esempio

Creare un alias chiave.

# create a key alias
$ ibmcloud kp key alias-create 24203f96-b134-440e-981a-a24f2d432256 my-alias

Creating key: 'my-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Alias
24203f96-b134-440e-981a-a24f2d432256   my-alias

Parametri obbligatori

  • KEY_ID

    L'ID della chiave che si desidera modificare. Per visualizzare l'elenco delle chiavi disponibili, esegui il comando kp keys.

  • KEY_ALIAS

    L'alias o l'identificativo alternativo della chiave che si desidera modificare. L'identificativo deve essere: alfanumerico, senza spazi o caratteri speciali diversi da '-' o '_' e non può essere un UUID versione 4.

  • -i, --instance-ID

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

Annullamento chiave kp - eliminazione

Una chiave con una politica dual-auth-delete richiede l'autorizzazione di due utenti di gestione per eliminare la chiave.

Questo comando (kp key cancel-delete) annulla o rimuove un'autorizzazione precedente.

Il Il comando kp key schedule - delete è l'"autorizzazione" per eliminare la chiave.

Seguire questo processo per eliminare una chiave con una normativa dual-auth-delete.

  1. Creare una chiave e abilitare la politica dual-auth-delete

  2. L'utente 1 pianifica (autorizza) l'eliminazione di una chiave con kp key schedule-delete comando

  3. L'utente 2 pianifica (autorizza) l'eliminazione di una chiave

  4. La chiave viene eliminata dopo l'esecuzione del secondo schedule-delete, che è supportato nell'interfaccia utente, API e CLI

  5. Se una seconda autorizzazione non si verifica entro 7 giorni, la chiave ritorna allo stato predefinito

Esistono due modi per abilitare la politica dual-auth-delete:

  • Impostare la politica per una singola chiave utilizzando kp key policy-update dual-auth-delete
  • Impostare la politica per l'istanza utilizzando kp instance policy-update dual-auth-delete; tutte le chiavi create dopo l'abilitazione della politica dell'istanza ereditano l'impostazione della politica dell'istanza
ibmcloud kp key cancel-delete KEY_ID_OR_ALIAS
    -i, --instance-id INSTANCE_ID

Esempio

Questo è un esempio di annullamento di un'eliminazione chiave precedentemente pianificata.

# this key has a dual-auth-delete policy
$ ibmcloud kp key policies $KEY_ID --output json

[
  {
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-22T19:13:00Z",
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:a192d603-0b8d-452f-aac3-f9e1f95e7411:policy:2427dbde-6cff-41eb-8b5a-ff26b038cafc",
    "lastUpdateDate": "2020-06-22T21:29:10Z",
    "updatedBy": "user id ...<redacted>...",
    "dualAuthDelete": { "enabled": true
    }
  }
]

# cancel a previously scheduled key delete
$ ibmcloud kp key cancel-delete $KEY_ID

Cancelling key for deletion...
OK

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o alias v4 della chiave che vuoi eliminare. Per visualizzare l'elenco delle chiavi disponibili, esegui il comando kp keys.

creazione chiave kp

Crea una chiave root nell'istanza Key Protect che specifichi o importa la tua chiave

Le chiavi root devono avere una lunghezza di 16, 24 o 32 byte; corrispondenti a 128, 192 o 256 bit.

ibmcloud kp key create KEY_NAME
        -i, --instance-id     INSTANCE_ID
    [--key-ring                KEY_RING_ID]
    [-k, --key-material    KEY_MATERIAL]
    [-n, --encrypted-nonce NONCE]
    [-o, --output          OUTPUT]
    [-s, --standard-key]
    [-v, --iv              IV]
    [-D, --description     DESCRIPTION]

Esempi

Questi sono esempi di kp key create.

Esempio 1

Creare una chiave root.

# create a root key
$ ibmcloud kp key create my-root-key

Creating key: 'my-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
24203f96-b134-440e-981a-a24f2d432256   my-root-key

Esempio 2

Crea una chiave root e mostra l'output JSON.

# create a root key
$ ibmcloud kp key create my-root-key --output json

{
    "id": "24203f96-b134-440e-981a-a24f2d432256",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:24203f96-b134-440e-981a-a24f2d432256"
}

Esempio 3

Crea una chiave root da un valore base64-encoded.

# create a random, base64-encoded, 32-byte key material
$ KEY_MATERIAL=$(openssl rand -base64 32)

# create a root key from a base64-encoded value
$ ibmcloud kp key create my-base64-root-key -k $KEY_MATERIAL

Creating key: 'my-base64-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
5f9eef2d-53b4-42e8-8b56-c2970255210a   my-base64-root-key

Esempio 4

Creare una chiave root utilizzando un token di importazione.

# create an import token that expires in 5 minutes and allows 10 retrievals
$ ibmcloud kp import-token create -e 300 -m 10

# create a random, base64-encoded, 32-byte key material
$ KEY_MATERIAL=$(openssl rand -base64 32)

# extract the nonce that was created by the "kp import-token create" command
$ NONCE=$(ibmcloud kp import-token show | jq -r '.["nonce"]')

# extract the public key that was created by the "kp import-token create" command
$ PUBLIC_KEY=$(ibmcloud kp import-token show | jq -r '.["payload"]')

# encrypt the key material using the public key
$ ibmcloud kp import-token key-encrypt -k $KEY_MATERIAL -p $PUBLIC_KEY

Encrypted Key
qT1pyiS1Sivbmmt4doTtfZC4XuLazk7u ...<redacted>... +a/6EqeAamo/9vo=

# capture the encrypted key material
$ ENCRYPTED_KEY=qT1pyiS1Sivbmmt4doTtfZC4XuLazk7u ...<redacted>... +a/6EqeAamo/9vo=

# encrypt the nonce
$ ibmcloud kp import-token nonce-encrypt -k $KEY_MATERIAL -n $NONCE

Encrypted Nonce                            IV
fR8uRvbrKIm9y/LCq9p6pwFBXbF864q/bw5meQ==   efQgA8xBeyuBy39D

# capture the encrypted nonce and the initialization vector (IV)
$ ENCRYPTED_NONCE=fR8uRvbrKIm9y/LCq9p6pwFBXbF864q/bw5meQ==
$ IV=efQgA8xBeyuBy39D

# create a root key using an import token, provide an encrypted key, nonce, and initialization vector (IV)
$ ibmcloud kp key create my-imported-root-key -k $ENCRYPTED_KEY -n $ENCRYPTED_NONCE -v $IV

Creating key: 'my-imported-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
4241a9b3-0ee0-4cfd-b0f3-fd80505fb675   my-imported-root-key

Esempio 5

Creare una chiave standard.

# create a standard key
$ ibmcloud kp key create my-standard-key -s

Creating key: 'my-standard-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
12d3f3a4-aea5-4832-8339-fa14dbffd935   my-standard-key

Esempio 6

Crea una chiave standard, utilizzata come vault per le credenziali.

Qualsiasi stringa base64-encoded può essere importata come chiave standard. Questo esempio mostra come memorizzare le credenziali, non solo le chiavi di cifratura, in Key Protect.

Le chiavi standard possono avere una dimensione massima di 7.500 byte prima della base64-encoding.

# create a file with your credentials
$ cat credentials.json

{
    "host": "localhost",
    "database": "dev-backup",
    "username": "my-username",
    "password": "my-password"
}

# encode the credentials (or any string) to a base64 string
$ ENCODED=$(base64 -i credentials.json)

$ echo $ENCODED

ewoJImhvc3QiOiAibG9jYWxob3N0IiwK...<redacted>...cGFzc3dvcmQiCn0K

# create a new key that contains the base64-encoded credentials
$ ibmcloud kp key create credentials-key -i $KP_INSTANCE_ID --key-material $ENCODED --standard-key --output json

# OR... CAPTURE THE KEY_ID
$ KEY_ID=$(ibmcloud kp key create credentials-key -i $KP_INSTANCE_ID --key-material $ENCODED --standard-key --output json | jq -r '.["id"]')

{
    "id": "8480e26f-3add-4fff-bca7-8cf908894b7c",
    "name": "credentials-key",
    "type": "application/vnd.ibm.kms.key+json",
    "extractable": true,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:a192d603-0b8d-452f-aac3-f9e1f95e7411:key:8480e26f-3add-4fff-bca7-8cf908894b7c",
    "deleted": false
}

# retrieve the base64-encoded payload
$ ibmcloud kp key show $KEY_ID --output json

# OR... CAPTURE THE PAYLOAD
$ PAYLOAD=$(ibmcloud kp key show $KEY_ID --output json | jq -r '.["payload"]')

{
    "id": "8480e26f-3add-4fff-bca7-8cf908894b7c",
    "name": "credentials-key",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-08-18T16:13:08Z",
    "lastUpdateDate": "2020-08-18T16:13:08Z",
    "extractable": true,
    "payload": "ewoJImhvc3QiOiAibG9jYWxob3N0IiwKCSJkYXRhYmFzZSI6ICJkZXYtYmFja3VwIiwKCSJ1c2VybmFtZSI6ICJteS11c2VybmFtZSIsCgkicGFzc3dvcmQiOiAibXktcGFzc3dvcmQiCn0=",
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:a192d603-0b8d-452f-aac3-f9e1f95e7411:key:8480e26f-3add-4fff-bca7-8cf908894b7c",
    "deleted": false,
    "dualAuthDelete": {
        "enabled": false
      }
}

# decode the payload to get the original string (credentials)
$ echo $PAYLOAD | base64 -d

{
    "host": "localhost",
    "database": "dev-backup",
    "username": "my-username",
    "password": "my-password"
}

Esempio 7

Creare una chiave root con un alias, quindi utilizzare tale alias per identificare la chiave per mostrare i dettagli della chiave.

# create a root key with an alias
$ ibmcloud kp key create root-key-with-alias -a example-alias --output json

{
    "id": "b3660416-4186-4587-b528-484886a4731b",
    "name": "root-key-with-alias",
    "type": "application/vnd.ibm.kms.key+json",
    "extractable": false,
    "state": 1,
    "aliases": [
        "example-alias"
    ],
    "keyRingID": "default",
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:b3660416-4186-4587-b528-484886a4731b",
    "deleted": false
}

# show key details using the alias as identifier
$ ibmcloud kp key show example-alias --output json

{
    "id": "b3660416-4186-4587-b528-484886a4731b",
    "name": "root-key-with-alias",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2022-06-09T21:21:55Z",
    "lastUpdateDate": "2022-06-09T21:21:55Z",
    "keyVersion": {
        "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "creationDate": "2022-06-09T21:21:55Z"
    },
    "aliases": [
        "example-alias"
    ],
    "keyRingID": "default",
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:b3660416-4186-4587-b528-484886a4731b",
    "deleted": false,
    "dualAuthDelete": {
        "enabled": false
    }
}

Esempio 8

Aggiungere una descrizione a una chiave. Ad esempio, una breve frase utilizzata per descrivere lo scopo previsto della chiave.

ibmcloud kp key create KEY_NAME -i 40f2a13c-780e-4641-bea5-e166e5bb5a9f -D ""description of the key""

Parametri obbligatori

  • KEY_NAME

    Un identificatore univoco e leggibile dall'utente da assegnare alla tua chiave.

  • -i, --instance-ID

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -k, --key-material

    Se hai generato una chiave, questo è il materiale della chiave base64-encoded che memorizzi e gestisci nel servizio.

    Le chiavi root devono avere una lunghezza di 16, 24 o 32 byte; corrispondenti a 128, 192 o 256 bit. La chiave deve essere base64-encoded.

    Le chiavi standard possono avere una dimensione massima di 7.500 byte. La chiave deve essere base64-encoded.

    Se stai creando una chiave utilizzando un token di importazione, questa è la chiave crittografata dal processo kp import-token key-encrypt.

    Per generare una nuova chiave, ometti il parametro -k, --key-material.

  • -n, --encrypted-nonce

    Da utilizzare con i token di importazione. Il valore nonce crittografato che verifica la tua richiesta per importare una chiave in Key Protect. Questo valore deve essere crittografato utilizzando il materiale di chiave importato nel servizio. Consultare ibmcloud kp import-token --help.

    Per recuperare un nonce, utilizzare ibmcloud kp import-token show. Quindi, crittografare il valore eseguendo il comando ibmcloud kp import-token nonce-encrypt``.

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

  • -s, --standard-key

    Impostare il parametro solo se si desidera creare una chiave standard. Per creare una chiave radice, ometti il parametro --standard-key.

  • -v, --iv

    Da utilizzare con i token di importazione. L'IV (initialization vector) generato quando crittografi un nonce. Il valore IV è richiesto per decrittografare il valore nonce crittografato che fornisci quando effettui una richiesta di importazione chiave al servizio.

    Per generare un IV, crittografare il nonce eseguendo il comando ibmcloud kp import-token nonce-encrypt``.

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

  • -D, --description

    Consente l'aggiunta di una descrizione alla chiave. Ad esempio, una breve frase utilizzata per descrivere lo scopo previsto della chiave.

chiavi kp create - key - with - policy - overrides

Crea una chiave con le politiche solo per la chiave denominata che sovrascriverà tutte le politiche dell'istanza applicabili.

ibmcloud kp key create-key-with-policy-overrides KEY_NAME
    -i, --instance-id                         INSTANCE_ID
    [-a, --aliases                            ALIAS]
    [-d, --dual-auth-delete-policy-enabled    KEY_RING_ID]
    [--key-ring                               KEY_RING_ID]
    [-k, --key-material                       KEY_MATERIAL]
    [-m, --rotation-interval-month            VALUE]
    [-n, --encrypted-nonce                    NONCE]
    [-o, --output                             OUTPUT]
    [-s, --standard-key]
    [-v, --iv                                 IV]

Esempio

Crea una chiave root che abilita una politica di rotazione con un intervallo di 2 mesi (ogni "mese" ha un valore di 30 giorni, con un conseguente intervallo di rotazione di 60 giorni).

% ibmcloud kp key create-key-with-policy-overrides test-key -m 2 -r
Creating key with policy overrides: 'test-key', in instance: '47377f07-8721-2O47-f396-ef1982c1e96e'...

OK
Key ID                                 Key Name   
076df396-4c90-e008-bf20-f1bb672d465b   test-key

# List policies
% ibmcloud kp key policies 076df396-4c90-e008-bf20-f1bb672d465b
Retrieving policy details for key ID: 076df396-4c90-e008-bf20-f1bb672d465b...
OK

Created By      IBMid-xxxxnnnnnxxx   
Creation Date   2022-10-27T17:48:20Z   
Last Updated    2022-10-27T17:48:20Z   
Updated By      IBMid-xxxxnnnnnxxx   
Policy Type     Rotation   
Interval        2   
Enabled         true

Parametri obbligatori

  • KEY_NAME

    Un identificatore univoco e leggibile dall'utente da assegnare alla tua chiave.

  • -i, --instance-ID

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -a, --aliases

    Nomi alias alfanumerici leggibili che vanno da 2 a 90 caratteri assegnati alla chiave. L'alias non può contenere spazi o caratteri speciali diversi da caratteri di sottolineatura e trattini. È consentito un massimo di 5 alias per chiave.

  • -d, --dual-auth-delete-policy-enabled

Abilita la politica di eliminazione dell'autenticazione doppia per una chiave.

  • -k, --key-material

    Se hai generato una chiave, questo è il materiale della chiave base64-encoded che memorizzi e gestisci nel servizio.

    Le chiavi root devono avere una lunghezza di 16, 24 o 32 byte; corrispondenti a 128, 192 o 256 bit. La chiave deve essere base64-encoded.

    Le chiavi standard possono avere una lunghezza massima di 7.500 byte. La chiave deve essere base64-encoded.

    Se stai creando una chiave utilizzando un token di importazione, questa è la chiave crittografata dal processo kp import-token key-encrypt.

    Per generare una nuova chiave, ometti il parametro -k, --key-material.

  • -n, --encrypted-nonce

    Da utilizzare con i token di importazione. Il valore nonce crittografato che verifica la tua richiesta per importare una chiave in Key Protect. Questo valore deve essere crittografato utilizzando il materiale di chiave importato nel servizio. Consultare ibmcloud kp import-token --help.

    Per recuperare un nonce, utilizzare ibmcloud kp import-token show. Quindi, crittografare il valore eseguendo il comando ibmcloud kp import-token nonce-encrypt``.

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

  • -m, --rotation-interval-month

Specifica l'intervallo di tempo di rotazione (in mesi) per una chiave. Il valore predefinito è -1.

  • -s, --standard-key

    Impostare il parametro solo se si desidera creare una chiave standard. Per creare una chiave radice, ometti il parametro --standard-key.

  • -v, --iv

    Da utilizzare con i token di importazione. L'IV (initialization vector) generato quando crittografi un nonce. Il valore IV è richiesto per decrittografare il valore nonce crittografato che fornisci quando effettui una richiesta di importazione chiave al servizio.

    Per generare un IV, crittografare il nonce eseguendo il comando ibmcloud kp import-token nonce-encrypt``.

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

eliminazione chiave kp

Elimina una chiave archiviata nel tuo servizio Key Protect.

ibmcloud kp key delete KEY_ID_OR_ALIAS
        -i, --instance-id INSTANCE_ID
    [--key-ring          KEY_RING_ID]
    [-f, --force]
    [-o, --output      OUTPUT]

Esempi

Questi sono esempi di kp key delete.

Esempio 1

Eliminare una chiave root.

# create a root key
$ ibmcloud kp key create my-root-key

Creating key: 'my-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
8635b804-9966-4918-a16b-d561fdbf181f   my-root-key

# show key details
$ ibmcloud kp key show 8635b804-9966-4918-a16b-d561fdbf181f

Grabbing info for key id: 8635b804-9966-4918-a16b-d561fdbf181f...
OK
Key ID                                 Key Name      Description   Creation Date                   Expiration Date
8635b804-9966-4918-a16b-d561fdbf181f   my-root-key                 2020-05-05 19:58:02 +0000 UTC   Key does not expire

# delete the key
$ ibmcloud kp key delete 8635b804-9966-4918-a16b-d561fdbf181f

Deleting key: 8635b804-9966-4918-a16b-d561fdbf181f, from instance: 390086ac-76fa-4094-8cf3-c0829bd69526...
OK
Deleted Key
8635b804-9966-4918-a16b-d561fdbf181f

Esempio 2

Elimina una chiave root e mostra l'output JSON.

# create a root key
$ ibmcloud kp key create my-root-key --output json

{
    "id": "9cca88c9-019e-4f0a-9e76-8e657c6b9720",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb145:390086ac-76fa-4094-8cf3-c0829bd69526:key:9cca88c9-019e-4f0a-9e76-8e657c6b9720"
}

# show key details
$ ibmcloud kp key show 9cca88c9-019e-4f0a-9e76-8e657c6b9720 --output json

{
    "id": "9cca88c9-019e-4f0a-9e76-8e657c6b9720",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-05-05T20:03:00Z",
    "lastUpdateDate": "2020-05-05T20:03:00Z",
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb145:390086ac-76fa-4094-8cf3-c0829bd69526:key:9cca88c9-019e-4f0a-9e76-8e657c6b9720"
}

# delete the key
$ ibmcloud kp key delete 9cca88c9-019e-4f0a-9e76-8e657c6b9720 --output json

{
    "id": "9cca88c9-019e-4f0a-9e76-8e657c6b9720"
}

Esempio 3

Eliminare una chiave root registrata con un'altra risorsa cloud.

# create a Cloud Object Storage (COS) instance
# "lite" is the pricing plan and "global" is the region
$ COS_NAME=my-cos-1

$ ibmcloud resource service-instance-create $COS_NAME cloud-object-storage lite global

# capture the COS instance id (GUID)
$ COS_INSTANCE_ID=9d4353d8-6b85-4689-90dd-1ccfb4a275ab

# create a Key Management Service (KMS) instance
# "tiered-pricing" is the pricing plan and "us-south" is the region
$ KMS_NAME=my-kms-1

$ ibmcloud resource service-instance-create $KMS_NAME kms tiered-pricing us-south

# capture the Key Protect (KP) instance id (GUID)
$ KP_INSTANCE_ID=b0d84b32-09d0-4314-8049-da78e3b9ab6f

# create a policy for COS to read KMS; source is COS, target is KMS (Key Protect)
$ ibmcloud iam authorization-policy-create cloud-object-storage kms Reader \
  --source-service-instance-id $COS_INSTANCE_ID \
  --target-service-instance-id $KP_INSTANCE_ID

# capture the COS-to-KMS authorization policy id
$ COS_KMS_AUTHORIZATION=79375168-2d74-49df-98aa-3e727410fa71

# create a KP root key that COS uses to encrypt data
$ ibmcloud kp key create my-cos-key --output json

{
    "id": "52a9d772-8982-4620-bfb4-b070dd812a0c",
    "name": "my-cos-key",
    "type": "application/vnd.ibm.kms.key+json",
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:b0d84b32-09d0-4314-8049-da78e3b9ab6f:key:52a9d772-8982-4620-bfb4-b070dd812a0c"
}

# capture the KP root key id
$ MY_COS_KEY_ID=52a9d772-8982-4620-bfb4-b070dd812a0c

# create a COS bucket and set KP encryption
#   must be done in the console user interface (UI) because
#   there is no API or CLI support at this time

# capture the name of the COS bucket that was created
$ COS_BUCKET=my-cos-kms-bucket

# view the KP registration; it's a result of creating the COS bucket
$ ibmcloud kp registrations --output json

[
  {
    "keyId": "52a9d772-8982-4620-bfb4-b070dd812a0c",
    "resourceCrn": "crn:v1:bluemix:public:cloud-object-storage:global:a/ea998d3389c3473aa0987652b46fb146:9d4353d8-6b85-4689-90dd-1ccfb4a275ab:bucket:my-cos-kms-bucket",
    "createdBy": "crn-crn:v1:bluemix:public:cloud-object-storage:global:a/ea998d3389c3473aa0987652b46fb146:9d4353d8-6b85-4689-90dd-1ccfb4a275ab::",
    "creationDate": "2020-06-15T20:41:23Z",
    "lastUpdated": "2020-06-15T20:41:23Z",
    "keyVersion": { "id": "52a9d772-8982-4620-bfb4-b070dd812a0c", "creationDate": "2020-06-15T20:36:46Z"
    }
  }
]

# delete the authorization policy between COS AND KMS - this breaks everything
$ ibmcloud iam authorization-policy-delete $COS_KMS_AUTHORIZATION --force

# delete the KP root key - this fails because the registration was not deleted
$ ibmcloud kp key delete $MY_COS_KEY_ID

Deleting key: 52a9d772-8982-4620-bfb4-b070dd812a0c, from instance: b0d84b32-09d0-4314-8049-da78e3b9ab6f...
FAILED
kp.Error:
    correlation_id='c27b7948-4a1f-4cbd-8770-cb3616888e27',
    msg='Conflict: Key could not be deleted. Please see "reasons" for more details.',
    reasons='[PROTECTED_RESOURCE_ERR: Key is protecting one or more cloud resources -
        FOR_MORE_INFO_REFER: https://cloud.ibm.com/docs/key-protect?topic=key-protect-troubleshooting#unable-to-delete-keys]'

# delete the KP root key; use --force because the registration between COS and KMS still exists
$ ibmcloud kp key delete $MY_COS_KEY_ID --force --output json

{
    "id": "52a9d772-8982-4620-bfb4-b070dd812a0c"
}

# delete the KMS instance
$ ibmcloud resource service-instance-delete $KMS_NAME --force

# delete the COS instance
$ ibmcloud resource service-instance-delete $COS_NAME --force

# view resources (COS and KMS should no longer exist)
$ ibmcloud resource service-instances

Retrieving instances with type service_instance in resource group Default in all locations under account <account name> as <email address>...
OK
No service instance found.

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o alias v4 della chiave che vuoi eliminare. Per visualizzare l'elenco delle chiavi disponibili, esegui il comando kp keys.

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -f, --force

    Eliminare una chiave, con la forza, che viene utilizzata per eliminare una chiave con "registrazioni". Le registrazioni sono associazioni tra chiavi root e altre risorse cloud, come i bucket COS ( Cloud Object Storage ) o le distribuzioni Cloud Databases.

    Per ulteriori informazioni, vedi Registrazioni kp

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

disabilitazione chiave kp

Il comando kp key disable disabilita una chiave root e revoca temporaneamente l'accesso ai dati associati della chiave nel cloud.

In qualità di amministratore, potrebbe essere necessario disabilitare una chiave root se si sospetta una possibile esposizione alla sicurezza, compromissione o violazione dei propri dati.

La disabilitazione di una chiave root sospende le operazioni di codifica e decodifica. Dopo aver confermato che un rischio di sicurezza non è più attivo, puoi ripristinare l'accesso ai tuoi dati abilitando la chiave root disabilitata.

Quando si disabilita una chiave root precedentemente abilitata, la chiave passa dallo stato Attivo (il valore è 1) allo stato della chiave Sospeso (il valore è 2).

Per disabilitare una chiave root, ti deve essere assegnato un ruolo di accesso al servizio Gestore per l'istanza o la chiave. Per informazioni su come i ruoli IAM vengono associati a Azioni del servizio Key Protect, controlla Ruoli di accesso al servizio.

Se stai utilizzando un servizio cloud integrato che supporta la revoca dell'accesso a una chiave root disabilitata, il servizio potrebbe impiegare fino a un massimo di 4 ore prima che l'accesso ai dati associati della chiave root venga revocato.

Dopo che l'accesso ai dati associati è stato revocato, un disable event corrispondente viene visualizzato nell'interfaccia web IBM Cloud Logs. disable event indica che la chiave è stata revocata (ed è ora disabilitata) e che la chiave non può essere utilizzata per le operazioni di codifica e decodifica.

ibmcloud kp key disable KEY_ID_OR_ALIAS
    -i, --instance-id INSTANCE_ID
    [--key-ring         KEY_RING_ID]

Esempi

Questi sono esempi di kp key disable.

Esempio 1

Creare una chiave root, disabilitarla, verificare lo stato della chiave (sospeso), abilitare la chiave root e verificare lo stato della chiave (attivo).

# create a root key
$ ibmcloud kp key create my-root-key --output json

{
    "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:264fadc3-7667-4b25-916e-5825fe70de0b"
}

# show key details - a state of "1" is "active"
$ ibmcloud kp key show 264fadc3-7667-4b25-916e-5825fe70de0b --output json

{
    "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-09T21:21:55Z",
    "lastUpdateDate": "2020-06-09T21:21:55Z",
    "keyVersion": {
        "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "creationDate": "2020-06-09T21:21:55Z"
    },
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:264fadc3-7667-4b25-916e-5825fe70de0b"
}

# disable the root key
$ ibmcloud kp key disable 264fadc3-7667-4b25-916e-5825fe70de0b

Disabling key: '264fadc3-7667-4b25-916e-5825fe70de0b', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK

# show key details - a state of "2" is "suspended"
$ ibmcloud kp key show 264fadc3-7667-4b25-916e-5825fe70de0b --output json

{
    "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-09T21:21:55Z",
    "lastUpdateDate": "2020-06-09T21:23:26Z",
    "keyVersion": {
        "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "creationDate": "2020-06-09T21:21:55Z"
    },
    "extractable": false,
    "state": 2,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:264fadc3-7667-4b25-916e-5825fe70de0b"
}

Esempio 2

Creare una chiave root, disabilitarla e tentare di utilizzare la chiave root per impacchettare un'altra chiave.

# create a root key
$ KEY_ID=$(ibmcloud kp key create my-root-key --output json | jq -r '.["id"]')

$ echo $KEY_ID

63d044d9-b38b-4803-85ef-ed9a1e5087c2

# disable the root key
$ ibmcloud kp key disable $KEY_ID

Disabling key: '63d044d9-b38b-4803-85ef-ed9a1e5087c2', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK

# create a random, base64-encoded, 32-byte data encryption key (DEK)
$ PLAINTEXT=$(openssl rand -base64 32)

$ echo $PLAINTEXT

BNxtU9B4kXOZA45Cnyz3wOh4J77TakTXI1n2rj0ZiMc=

# wrap the plaintext key with the root key, creating a DEK (this is the ciphertext)
# this should fail (the root key is disables)
$ ibmcloud kp key wrap $KEY_ID -p $PLAINTEXT --output json

FAILED
kp.Error:
    correlation_id='c2edbdad-7e62-4690-8fcc-10515ade9913',
    msg='Conflict: Action could not be performed on key. Please see "reasons" for more details.',
    reasons='[KEY_ACTION_INVALID_STATE_ERR: Key is not in a valid state -
        FOR_MORE_INFO_REFER: https://cloud.ibm.com/apidocs/key-protect]'

Esempio 3

Creare una chiave root con un alias, utilizzare tale alias per identificare la chiave da disabilitare, verificare lo stato della chiave (sospeso), quindi abilitare la chiave root e verificare il nuovo stato della chiave (attivo).

# create a root key
$ ibmcloud kp key create root-key-with-alias -a example-alias-1 --output json

{
    "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "name": "root-key-with-alias",
    "type": "application/vnd.ibm.kms.key+json",
    "extractable": false,
    "state": 1,
    "aliases": [
        "example-alias"
    ],
    "deleted": false,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:264fadc3-7667-4b25-916e-5825fe70de0b"
}

# show key details using the alias as identifier - a state of "1" is "active"
$ ibmcloud kp key show example-alias-1 --output json

{
    "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "name": "root-key-with-alias",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-09T21:21:55Z",
    "lastUpdateDate": "2020-06-09T21:21:55Z",
    "keyVersion": {
        "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "creationDate": "2020-06-09T21:21:55Z"
    },
    "extractable": false,
    "state": 1,
    ...
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:264fadc3-7667-4b25-916e-5825fe70de0b"
}

# disable the root key identified by alias
$ ibmcloud kp key disable example-alias-1

Disabling key: '264fadc3-7667-4b25-916e-5825fe70de0b', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK

# show key details - a state of "2" is "suspended"
$ ibmcloud kp key show example-alias-1 --output json

{
    "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "name": "root-key-with-alias",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-09T21:21:55Z",
    "lastUpdateDate": "2020-06-09T21:23:26Z",
    "keyVersion": {
        "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "creationDate": "2020-06-09T21:21:55Z"
    },
    "extractable": false,
    "state": 2,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:264fadc3-7667-4b25-916e-5825fe70de0b"
}

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o alias v4 della chiave che vuoi eliminare. Per visualizzare l'elenco delle chiavi disponibili, esegui il comando kp keys.

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

abilitazione chiave kp

Quando si abilita una chiave root precedentemente disabilitata, la chiave passa dallo stato Sospeso (il valore è 2) allo stato della chiave Attivo (il valore è 1). Questa azione ripristina le operazioni di codifica e decodifica della chiave.

Se stai utilizzando un servizio cloud integrato che supporta il ripristino dell'accesso a una chiave root disabilitata, il servizio potrebbe richiedere fino a un massimo di 4 ore prima che venga ripristinato l'accesso ai dati associati della chiave root.

Una volta ripristinato l'accesso ai dati associati, un enable event corrispondente viene visualizzato nell'interfaccia web IBM Cloud Logs. enable event indica che la chiave è stata ripristinata (ed è ora abilitata) e può essere utilizzata per le operazioni di codifica e decodifica, come ad esempio il wrap, unwrap e rewrap.

ibmcloud kp key enable <KEY_ID_OR_ALIAS> -i <INSTANCE_ID> [ --key-ring KEY_RING_ID]

Esempi

Questo è un esempio di kp key enable.

# create a root key
$ ibmcloud kp key create my-root-key --output json

{
    "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:264fadc3-7667-4b25-916e-5825fe70de0b"
}

# show key details - a state of "1" is "active"
$ ibmcloud kp key show 264fadc3-7667-4b25-916e-5825fe70de0b --output json

{
    "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-09T21:21:55Z",
    "lastUpdateDate": "2020-06-09T21:21:55Z",
    "keyVersion": {
        "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "creationDate": "2020-06-09T21:21:55Z"
    },
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:264fadc3-7667-4b25-916e-5825fe70de0b"
}

# disable the root key
$ ibmcloud kp key disable 264fadc3-7667-4b25-916e-5825fe70de0b

Disabling key: '264fadc3-7667-4b25-916e-5825fe70de0b', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK

# show key details - a state of "2" is "suspended"
$ ibmcloud kp key show 264fadc3-7667-4b25-916e-5825fe70de0b --output json

{
    "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-09T21:21:55Z",
    "lastUpdateDate": "2020-06-09T21:23:26Z",
    "keyVersion": {
        "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "creationDate": "2020-06-09T21:21:55Z"
    },
    "extractable": false,
    "state": 2,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:264fadc3-7667-4b25-916e-5825fe70de0b"
}

# enable the key
$ ibmcloud kp key enable 264fadc3-7667-4b25-916e-5825fe70de0b

Enabling key: '264fadc3-7667-4b25-916e-5825fe70de0b', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK

# show key details - a state of "1" is "active"
$ ibmcloud kp key show 264fadc3-7667-4b25-916e-5825fe70de0b --output json

{
    "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-09T21:21:55Z",
    "lastUpdateDate": "2020-06-09T21:31:44Z",
    "keyVersion": {
        "id": "264fadc3-7667-4b25-916e-5825fe70de0b",
    "creationDate": "2020-06-09T21:21:55Z"
    },
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:264fadc3-7667-4b25-916e-5825fe70de0b"
}

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o alias v4 della chiave che vuoi eliminare. Per visualizzare l'elenco delle chiavi disponibili, esegui il comando kp keys.

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

politiche chiave kp

Richiama i dettagli su una politica della chiave, ad esempio l'intervallo di rotazione automatica della chiave.

ibmcloud kp key policies KEY_ID_OR_ALIAS
        -i, --instance-id INSTANCE_ID
    [--key-ring          KEY_RING_ID]
    [-d, --dual-auth]
    [-o, --output      OUTPUT]
    [-r, --rotation]

Esempio

Questo esempio elenca le politiche per una chiave root.

Le politiche chiave sono: eliminazione doppia autorizzazione e rotazione.

# create a root key
$ KEY_ID=$(ibmcloud kp key create my-root-key --output json | jq -r '.["id"]')

$ echo $KEY_ID

c024c2b3-2093-46e5-aabb-fdf8cbc14e44

# show key details
$ ibmcloud kp key show $KEY_ID --output json

{
    "id": "c024c2b3-2093-46e5-aabb-fdf8cbc14e44",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-18T20:34:39Z",
    "lastUpdateDate": "2020-06-18T20:34:39Z",
    "keyVersion": {
        "id": "c024c2b3-2093-46e5-aabb-fdf8cbc14e44",
    "creationDate": "2020-06-18T20:34:39Z"
    },
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:a192d603-0b8d-452f-aac3-f9e1f95e7411:key:c024c2b3-2093-46e5-aabb-fdf8cbc14e44"
}

# update the policy and rotate the key every 2 months
$ ibmcloud kp key policy-update rotation $KEY_ID -m 2 --output json

{
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-18T20:35:41Z",
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:a192d603-0b8d-452f-aac3-f9e1f95e7411:policy:06a40fd6-6fd7-460a-87d7-8388fc1be057",
    "lastUpdateDate": "2020-06-18T20:35:41Z",
    "updatedBy": "user id ...<redacted>...",
    "rotation": {
        "interval_month": 2
      }
}

# list the policies
$ ibmcloud kp key policies $KEY_ID --output json

[
  {
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-18T20:35:41Z",
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:a192d603-0b8d-452f-aac3-f9e1f95e7411:policy:06a40fd6-6fd7-460a-87d7-8388fc1be057",
    "lastUpdateDate": "2020-06-18T20:35:41Z",
    "updatedBy": "user id ...<redacted>...",
    "rotation": { "interval_month": 2
    }
  }
]

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o alias v4 della chiave che vuoi interrogare. Per visualizzare l'elenco delle chiavi disponibili, esegui il comando kp keys.

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -d, --dual-auth

    Mostra le politiche che dispongono di una politica dual-auth-delete.

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

  • -r, --rotation

    Mostra le politiche che dispongono di una politica rotation.

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

Politica chiave kp - update dual - auth - delete

Puoi utilizzare Key Protect per eliminare in modo sicuro le chiavi di crittografia utilizzando un processo di autenticazione doppia. Quando elimini una chiave, ne distruggi in modo permanente il contenuto e i dati associati. Tutti i dati crittografati dalla chiave diventano inaccessibili.

L'eliminazione di una chiave che ha una politica di autorizzazione doppia richiede un'autorizzazione da due utenti. Con la Key Protect API, è possibile fornire la prima autorizzazione impostando la chiave per la cancellazione. Successivamente, un altro utente fornisce una seconda autorizzazione utilizzando l’ interfaccia grafica o l’ API per eliminare la chiave.

ibmcloud kp key policy-update dual-auth-delete KEY_ID_OR_ALIAS
        -i, --instance-id INSTANCE_ID
        -e, --enable
    [--key-ring          KEY_RING_ID]
    [-o, --output      OUTPUT]

Esempio

Questo esempio abilita la politica di eliminazione della doppia autorizzazione.

# create a root key
$ KEY_ID=$(ibmcloud kp key create my-root-key --output json | jq -r '.["id"]')

$ echo $KEY_ID

d887bfe8-5166-4dad-af32-7e3055ca1873

# show key details
$ ibmcloud kp key show $KEY_ID --output json

{
    "id": "d887bfe8-5166-4dad-af32-7e3055ca1873",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-19T16:07:50Z",
    "lastUpdateDate": "2020-06-19T16:07:50Z",
    "keyVersion": {
        "id": "d887bfe8-5166-4dad-af32-7e3055ca1873",
    "creationDate": "2020-06-19T16:07:50Z"
    },
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:a192d603-0b8d-452f-aac3-f9e1f95e7411:key:d887bfe8-5166-4dad-af32-7e3055ca1873"
}

# enable the dual authorization policy
$ ibmcloud kp key policy-update dual-auth-delete $KEY_ID --enable --output json

{
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-19T16:08:59Z",
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:a192d603-0b8d-452f-aac3-f9e1f95e7411:policy:0aab763d-b650-43a2-86ad-bdfe2c35c94c",
    "lastUpdateDate": "2020-06-19T16:08:59Z",
    "updatedBy": "user id ...<redacted>...",
    "dualAuthDelete": {
        "enabled": true
      }
}

# list the policies
$ ibmcloud kp key policies $KEY_ID --output json

[
  {
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-19T16:08:59Z",
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:a192d603-0b8d-452f-aac3-f9e1f95e7411:policy:0aab763d-b650-43a2-86ad-bdfe2c35c94c",
    "lastUpdateDate": "2020-06-19T16:08:59Z",
    "updatedBy": "user id ...<redacted>...",
    "dualAuthDelete": { "enabled": true
    }
  }
]

# this should fail (the key has a dual authorization policy)
$ ibmcloud kp key delete $KEY_ID_OR_ALIAS

Deleting key: d887bfe8-5166-4dad-af32-7e3055ca1873, from instance: a192d603-0b8d-452f-aac3-f9e1f95e7411...
FAILED
kp.Error:
    correlation_id='fe0db627-1726-4827-a9d2-c21d728e1c92',
    msg='Conflict: 1 prior authorization(s) are required for deletion: Key could not be deleted.
        Please see "reasons" for more details.',
    reasons='[AUTHORIZATIONS_NOT_MET: Number of authorizations required to delete is not met -
        FOR_MORE_INFO_REFER: https://cloud.ibm.com/apidocs/key-protect]'

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o alias v4 della chiave che vuoi interrogare. Per visualizzare l'elenco delle chiavi disponibili, esegui il comando kp keys.

  • -e, --enable

    Una volta abilitata la politica dual - auth - delete, non è possibile disabilitarla. Non puoi eliminare una chiave senza due (doppie) autorizzazioni. Il processo deve essere completato entro 7 giorni, altrimenti la politica di doppia autorizzazione viene automaticamente annullata, il che significa che la chiave può essere eliminata da chiunque abbia l'autorizzazione (non sono necessarie due autorizzazioni).

    Se la politica di autorizzazione doppia è stata abilitata accidentalmente e si desidera eliminare la chiave, è possibile disable la chiave (utilizzando il comando kp key disable ) e attendere 7 giorni per la scadenza della politica di autorizzazione doppia. A questo punto è possibile eliminare la chiave.

    non puoi eliminare l'istanza Key Protect finché le loro chiavi attive. Una chiave con una doppia politica di autorizzazione è una chiave attiva.

Parametri facoltativi

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

Politica chiave kp - aggiorna rotazione

Quando configuri una politica di rotazione automatica per una chiave root, ne abbrevi il ciclo di vita ad intervalli regolari e limiti la quantità di informazioni da essa protetta. Gli utenti possono anche abilitare o disabilitare la politica di rotazione della chiave su una chiave.

È possibile creare una politica di rotazione solo per le chiavi root generate in Key Protect. Se inizialmente hai importato la chiave radice, devi fornire un nuovo materiale chiave base64-encoded per effettuare la rotazione della chiave. Per ulteriori informazioni, vedi Rotazione delle chiavi root su richiesta.

ibmcloud kp key policy-update rotation KEY_ID|KEY_ALIAS
[--enable | --disable] [-m MONTHLY_INTERVAL] [-o FORMAT]
[--key-ring KEY_RING_ID]

Esempi

Le politiche di rotazione possono essere applicate al momento della creazione della chiave o dopo la creazione di una chiave. Nel primo esempio, creiamo semplicemente la chiave senza una politica di rotazione:

# create a root key

ibmcloud kp key create rotateKeyEnableDisableDemo

Creating key: 'rotateKeyEnableDisableDemo', in instance: '5ecfe306-d4at-48c0-ab07-b5c5bc751534'...
OK
Key ID                                 Key Name   
4d5540bd-3235-4a46-a8af-974f7ed6558a   rotateKeyEnableDisableDemo   
---------------------------------------------------------------------------------------------------------------------------------------------------
# set a rotation policy of three months

ibmcloud kp key policy-update rotation 4d5540bd-3235-4a46-a8af-974f7ed6558a -m 3 -e --output json

{
        "createdBy": "user id ...<redacted>...",
        "creationDate": "2022-12-02T00:50:11Z",
        "crn": "crn:v1:bluemix:public:kms:us-south:a/e3e8fd14a61a49cda102faad15b06c09:5ecfe306-d4af-48c0-ab07-b5c5bc751534:policy:0ec7ad62-982d-45bb-895f-986d95015f5b",
        "lastUpdateDate": "2022-12-02T00:51:38Z",
        "updatedBy": "user id ...<redacted>...",
        "rotation": {
                "enabled": true,
                "interval_month": 3
        }
}
---------------------------------------------------------------------------------------------------------------------------------------------------
# show the rotation policy for this key

ibmcloud kp key policies 4d5540bd-3235-4a46-a8af-974f7ed6558a -r --output json

{
        "createdBy": "user id ...<redacted>...",
        "creationDate": "2022-12-02T00:50:11Z",
        "crn": "crn:v1:bluemix:public:kms:us-south:a/e3e8fd14a61a49cda102faad15b06c09:5ecfe306-d4af-48c0-ab07-b5c5bc751534:policy:0ec7ad62-982d-45bb-895f-986d95015f5b",
        "lastUpdateDate": "2022-12-02T00:51:38Z",
        "updatedBy": "user id ...<redacted>...",
        "rotation": {
                "enabled": true,
                "interval_month": 2
        }
}
---------------------------------------------------------------------------------------------------------------------------------------------------
# update the policy to three months

ibmcloud kp key policy-update rotation 4d5540bd-3235-4a46-a8af-974f7ed6558a -m 3 -e --output json

{
        "createdBy": "user id ...<redacted>...",
        "creationDate": "2022-12-02T00:50:11Z",
        "crn": "crn:v1:bluemix:public:kms:us-south:a/e3e8fd14a61a49cda102faad15b06c09:5ecfe306-d4af-48c0-ab07-b5c5bc751534:policy:0ec7ad62-982d-45bb-895f-986d95015f5b",
        "lastUpdateDate": "2022-12-02T00:51:38Z",
        "updatedBy": "user id ...<redacted>...",
        "rotation": {
                "enabled": true,
                "interval_month": 3
        }
}
---------------------------------------------------------------------------------------------------------------------------------------------------
# disable the policy for this key

ibmcloud kp key policy-update rotation 4d5540bd-3235-4a46-a8af-974f7ed6558a -d --output json

{
        "createdBy": "user id ...<redacted>...",
        "creationDate": "2022-12-02T00:50:11Z",
        "crn": "crn:v1:bluemix:public:kms:us-south:a/e3e8fd14a61a49cda102faad15b06c09:5ecfe306-d4af-48c0-ab07-b5c5bc751534:policy:0ec7ad62-982d-45bb-895f-986d95015f5b",
        "lastUpdateDate": "2022-12-02T00:52:52Z",
        "updatedBy": "user id ...<redacted>...",
        "rotation": {
                "enabled": false,
                "interval_month": 3
        }
}
---------------------------------------------------------------------------------------------------------------------------------------------------
# show that the policy has been disabled

ibmcloud kp key policies 4d5540bd-3235-4a46-a8af-974f7ed6558a -r --output json

{
        "createdBy": "user id ...<redacted>...",
        "creationDate": "2022-12-02T00:50:11Z",
        "crn": "crn:v1:bluemix:public:kms:us-south:a/e3e8fd14a61a49cda102faad15b06c09:5ecfe306-d4af-48c0-ab07-b5c5bc751534:policy:0ec7ad62-982d-45bb-895f-986d95015f5b",
        "lastUpdateDate": "2022-12-02T00:52:52Z",
        "updatedBy": "user id ...<redacted>...",
        "rotation": {
                "enabled": false,
                "interval_month": 3
        }
}
---------------------------------------------------------------------------------------------------------------------------------------------------

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o alias v4 della chiave che vuoi interrogare. Per visualizzare l'elenco delle chiavi disponibili, esegui il comando kp keys.

Parametri facoltativi

  • -m, --monthly-interval

    Impostare l'intervallo di rotazione chiave in mesi. L'intervallo di rotazione deve essere compreso tra 1 e 12 mesi.

  • -e, --enable o -d, --disable

    Per impostazione predefinita, la politica di rotazione delle chiavi è abilitata. Se l'utente vuole disabilitare o abilitare il criterio, può usare rispettivamente -d(--disable) o -e(--enable).

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

ripristino chiave kp

Key Protect può ripristinare una chiave root precedentemente eliminata, che ripristina l'accesso ai dati associati nel cloud.

Come amministratore, potrebbe essere necessario ripristinare una chiave root importata in Key Protect per accedere ai dati la chiave precedentemente protetta.

Quando si ripristina una chiave, si sposta la chiave da Destroyed (il valore è 5) allo stato della chiave Attivo (il valore è 1) e si ripristina l'accesso a tutti i dati precedentemente codificati con la chiave.

È possibile ripristinare una chiave eliminata entro 30 giorni dalla sua eliminazione. Questa capacità è disponibile solo per le chiavi root create con un key material.

È possibile ripristinare solo le chiavi root create con un key material, utilizzando kp key create con opzione -k, --key-material. Non è possibile ripristinare una chiave root se l'opzione --key-material non è stata specificata.

Se si desidera ripristinare una chiave root eliminata, è necessario salvare la key material utilizzato per creare la chiave root. Non è possibile ripristinare una chiave eliminata senza aver fornito il key material originale.

ibmcloud kp key restore KEY_ID_OR_ALIAS
        -i, --instance-id     INSTANCE_ID
        -k, --key-material    KEY_MATERIAL
    [--key-ring          KEY_RING_ID]
    [-n, --encrypted-nonce ENCRYPTED_NONCE]
    [-v, --iv              IV]

Esempi

Questi sono esempi di kp key restore.

Esempio 1

Questo esempio crea una chiave root utilizzando un materiale della chiave, elimina la chiave, quindi ripristina la chiave.

# create a random, base64-encoded, 32-byte key material
$ KEY_MATERIAL=$(openssl rand -base64 32)

$ echo $KEY_MATERIAL

4EZBMBMkZ87z4nvYsQH21DC5+wslgWhHRiU8bmqJ4CY=

# create a root key from a base64-encoded value
$ KEY_ID=$(ibmcloud kp key create my-base64-root-key -k $KEY_MATERIAL --output json | jq -r '.["id"]')

$ echo $KEY_ID

62ad0cd5-70a4-4c4d-9d87-5f4db620b120

# delete the root key
$ ibmcloud kp key delete $KEY_ID

Deleting key: 62ad0cd5-70a4-4c4d-9d87-5f4db620b120, from instance: a192d603-0b8d-452f-aac3-f9e1f95e7411...
OK
Deleted Key
62ad0cd5-70a4-4c4d-9d87-5f4db620b120

# list keys - verify the key was deleted
$ ibmcloud kp keys

Retrieving keys...
OK
Key ID   Key Name

# restore the deleted key
$ ibmcloud kp key restore $KEY_ID -k $KEY_MATERIAL --output json

{
    "id": "62ad0cd5-70a4-4c4d-9d87-5f4db620b120",
    "name": "my-base64-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:a192d603-0b8d-452f-aac3-f9e1f95e7411:key:62ad0cd5-70a4-4c4d-9d87-5f4db620b120"
}

# list keys - verify the key was restored
$ ibmcloud kp keys

Retrieving keys...
OK
Key ID                                 Key Name
62ad0cd5-70a4-4c4d-9d87-5f4db620b120   my-base64-root-key

Esempio 2

Questo flusso di lavoro crea una chiave root utilizzando un token di importazione, elimina la chiave e ripristina la chiave.

Si tratta di un processo in due fasi.

  1. Creare una chiave root utilizzando un token di importazione e quindi eliminare la chiave

  2. Creare un token di importazione, richiesto per ripristinare la chiave e ripristinare la chiave

La creazione di una chiave root utilizzando un token di importazione ha un limite di tempo (il -e, --expiration ). Quando si ripristina una chiave è necessario un token di importazione. Ecco perché è necessario passare attraverso un processo di importazione di token per ripristinare una chiave.

Passo 1- crea una chiave root utilizzando un token di importazione e quindi elimina la chiave

# create an import token that expires in 5 minutes and allows 10 retrievals
$ ibmcloud kp import-token create -e 300 -m 10

Created                         Expires                         Max Retrievals   Remaining Retrievals
2020-06-18 12:21:59 +0000 UTC   2020-06-18 12:26:59 +0000 UTC   10               10

# create a random, base64-encoded, 32-byte key material
$ KEY_MATERIAL=$(openssl rand -base64 32)

$ echo $KEY_MATERIAL

sADDNDE3pcJlbYXu2z5QFORvsxV1PosRiAPERrhYJdk=

# extract the nonce that was created by the "kp import-token create" command
$ NONCE=$(ibmcloud kp import-token show | jq -r '.["nonce"]')

$ echo $NONCE

/QhqOsqlVPC+ZPWz

# extract the public key that was created by the "kp import-token create" command
$ PUBLIC_KEY=$(ibmcloud kp import-token show | jq -r '.["payload"]')

$ echo $PUBLIC_KEY

LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0t ...<redacted>... QyBLRVktLS0tLQo=

# encrypt the key material using the public key
$ ibmcloud kp import-token key-encrypt -k $KEY_MATERIAL -p $PUBLIC_KEY

Encrypted Key
C+/puHn1v5p7aohitM4r6N4ohiVkCecP ...<redacted>... eWmJRuvsSxDg/OY=

# capture the encrypted key material
$ ENCRYPTED_KEY=C+/puHn1v5p7aohitM4r6N4ohiVkCecP ...<redacted>... eWmJRuvsSxDg/OY=

# encrypt the nonce
$ ibmcloud kp import-token nonce-encrypt -k $KEY_MATERIAL -n $NONCE

Encrypted Nonce                            IV
TxrgdayWnM5OB3JoYuQR97oulxvREptk8TzciQ==   7BiIpcbGxXBzuXZP

# capture the encrypted nonce and the initialization vector (IV)
$ ENCRYPTED_NONCE=TxrgdayWnM5OB3JoYuQR97oulxvREptk8TzciQ==
$ IV=7BiIpcbGxXBzuXZP

# create a root key using an import token, provide an encrypted key, nonce, and initialization vector (IV)
$ KEY_ID=$(ibmcloud kp key create my-imported-root-key -k $ENCRYPTED_KEY -n $ENCRYPTED_NONCE -v $IV --output json | jq -r '.["id"]')

$ echo $KEY_ID

c42c6f2c-8b67-4016-b2c3-99fba9490f5d

# list keys - verify the key was created
$ ibmcloud kp keys

Retrieving keys...
OK
Key ID                                 Key Name
c42c6f2c-8b67-4016-b2c3-99fba9490f5d   my-imported-root-key

# delete the root key
$ ibmcloud kp key delete $KEY_ID

Deleting key: c42c6f2c-8b67-4016-b2c3-99fba9490f5d, from instance: a192d603-0b8d-452f-aac3-f9e1f95e7411...
OK
Deleted Key
c42c6f2c-8b67-4016-b2c3-99fba9490f5d

# list keys - verify the key was deleted
$ ibmcloud kp keys

Retrieving keys...
OK
Key ID   Key Name

Passo 2- crea un token di importazione, che è richiesto per ripristinare la chiave e ripristinare la chiave

# NOTE: "kp key restore" requires an import token to complete the process,
# if you follow this example, the previously created import token may still
# exist and the example works; otherwise, if the import token has expired then
# you need to create a new import token prior to restoring the key

# create an import token that expires in 5 minutes and allows 10 retrievals
$ ibmcloud kp import-token create -e 300 -m 10

Created                         Expires                         Max Retrievals   Remaining Retrievals
2020-06-18 12:30:54 +0000 UTC   2020-06-18 12:35:54 +0000 UTC   10               10

# extract the nonce that was created by the "kp import-token create" command
$ NONCE=$(ibmcloud kp import-token show | jq -r '.["nonce"]')

$ echo $NONCE

N3x8F0ihAZ51nj6M

# extract the public key that was created by the "kp import-token create" command
$ PUBLIC_KEY=$(ibmcloud kp import-token show | jq -r '.["payload"]')

$ echo $PUBLIC_KEY

LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0t ...<redacted>... QyBLRVktLS0tLQo=

# encrypt the key material using the public key
$ ibmcloud kp import-token key-encrypt -k $KEY_MATERIAL -p $PUBLIC_KEY

Encrypted Key
Ch7hcsT1EOfSdghjOHKAemBZuzDoqJoH ...<redacted>... F4p/mkGT/EQJS5o=

# capture the encrypted key material
$ ENCRYPTED_KEY=Ch7hcsT1EOfSdghjOHKAemBZuzDoqJoH ...<redacted>... F4p/mkGT/EQJS5o=

# encrypt the nonce
$ ibmcloud kp import-token nonce-encrypt -k $KEY_MATERIAL -n $NONCE

Encrypted Nonce                            IV
nrrCczvYXvc6T7J2G+EOLjHZO1cpPyu/nhsIlA==   N6oLJnUqaKF3v5Sd

# capture the encrypted nonce and the initialization vector (IV)
$ ENCRYPTED_NONCE=nrrCczvYXvc6T7J2G+EOLjHZO1cpPyu/nhsIlA==
$ IV=N6oLJnUqaKF3v5Sd

# restore the deleted key
$ ibmcloud kp key restore $KEY_ID -k $ENCRYPTED_KEY -n $ENCRYPTED_NONCE -v $IV --output json

{
    "id": "c42c6f2c-8b67-4016-b2c3-99fba9490f5d",
    "name": "my-imported-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:a192d603-0b8d-452f-aac3-f9e1f95e7411:key:c42c6f2c-8b67-4016-b2c3-99fba9490f5d"
}

# list keys - verify the key was restored
$ ibmcloud kp keys

Retrieving keys...
OK
Key ID                                 Key Name
c42c6f2c-8b67-4016-b2c3-99fba9490f5d   my-imported-root-key

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o alias v4 della chiave che si desidera ripristinare.

  • -i, --instance-ID

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -k, --key-material

    Deprecated Il materiale della chiave da una chiave base64-encoded precedentemente importata.

    Se hai creato la chiave root utilizzando un import token, il valore dell'opzione -k, --key-material è la chiave del materiale crittografata. Vedere l'esempio 2, che utilizza un token di importazione per creare la chiave root e utilizza un token di importazione per ripristinare la chiave root.

  • -n, --encrypted-nonce

    Deprecated Verifica una richiesta di importare una chiave fornendo un nonce codificato.

    Per ulteriori informazioni, consultare kp import - token nonce - encrypt.

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

  • -v, --iv

    Deprecated Fornire il vettore di inizializzazione (IV) generato dopo la crittografia di un nonce.

    Per ulteriori informazioni, consultare kp import - token nonce - encrypt.

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

portachiavi kp

Elencare i keyring associati all'istanza kp.

Esempio

L'esempio mostra l'utilizzo del plugin CLI per elencare i keyring appropriati per l'istanza fornita.

ibmcloud kp key-rings -i <INSTANCE_ID>

Parametri obbligatori

  • -i, --instance-ID

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

creazione key - ring kp

Creare un keyring all'interno di una istanza kp.

Esempio

L'esempio mostra l'utilizzo del plug-in CLI per creare un keyring nell'istanza fornita.

ibmcloud kp key-ring create KEY_RING_ID -i <INSTANCE_ID>

Parametri obbligatori

  • KEY_RING_ID

    Il riferimento alfanumerico più lungo o uguale a 2 caratteri e inferiore o uguale a 100 per il key ring.

  • -i, --instance-ID

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

eliminazione key - ring kp

Eliminare un keyring all'interno di una istanza kp.

Esempio

L'esempio mostra l'utilizzo del plugin CLI per eliminare un keyring nell'istanza fornita. Notare che la forza (-f) è stata aggiunta.

ibmcloud kp key-ring delete KEY_RING_ID -i <INSTANCE_ID> -f

Parametri obbligatori

  • KEY_RING_ID

    Il riferimento alfanumerico più lungo o uguale a 2 caratteri e inferiore o uguale a 100 per il key ring.

  • -i, --instance-ID

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -f, --force

    La forzatura elimina un keyring che ha ancora le chiavi nello stato Distrutto . Non elimina i keyring che hanno chiavi in un altro stato. Se un file di chiavi contiene chiavi nello stato Destroyed e questo indicatore non viene aggiunto, l'eliminazione del file di chiavi non riesce.

rotazione chiave kp

Esegui la rotazione di una chiave root archiviata nel tuo servizio Key Protect.

Quando ruoti la tua chiave root, sostituisci la chiave con un nuovo materiale della chiave.

Se Key Protect ha creato la chiave (la chiave era non creato con il parametro -k ) Key Protect crea una nuova chiave. Non è possibile specificare kp key rotate con -k parametro.

Se hai creato una chiave e hai fornito il materiale della chiave (kp key create key-name -k $KEY_MATERIAL), devi fornire un nuovo materiale della chiave quando ruoti la chiave (kp key rotate $KEY_ID_OR_ALIAS -k $NEW_KEY_MATERIAL)

Non è possibile ruotare una chiave standard, ovvero una chiave creata utilizzando kp create key-name --standard-key .

ibmcloud kp key rotate KEY_ID_OR_ALIAS
        -i, --instance-id  INSTANCE_ID
    [--key-ring           KEY_RING_ID]
    [-k, --key-material KEY_MATERIAL]

Esempi

Questi sono esempi di kp key rotate.

Esempio 1

Ruotare una chiave root.

# create a root key
$ ibmcloud kp key create my-root-key

Creating key: 'my-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
1a6d5be8-287c-4eb3-9c44-cf0c2b0d67ad   my-root-key

# rotate the key
$ ibmcloud kp key rotate 1a6d5be8-287c-4eb3-9c44-cf0c2b0d67ad

Rotating root key...
OK

# show key details
$ ibmcloud kp key show 1a6d5be8-287c-4eb3-9c44-cf0c2b0d67ad

Grabbing info for key id: 1a6d5be8-287c-4eb3-9c44-cf0c2b0d67ad...
OK
Key ID                                 Key Name      Description   Creation Date                   Expiration Date
1a6d5be8-287c-4eb3-9c44-cf0c2b0d67ad   my-root-key                 2020-05-06 17:25:22 +0000 UTC   Key does not expire

# create a new key material
$ NEW_KEY_MATERIAL=$(openssl rand -base64 32)

# Key Protect created the root key, providing a new key material will fail
$ ibmcloud kp key rotate 1a6d5be8-287c-4eb3-9c44-cf0c2b0d67ad -k $NEW_KEY_MATERIAL

Rotating root key...
FAILED

Esempio 2

Ruota una base64-encoded o una chiave token importata.

Per prima cosa, crea una chiave root da un Valorebase64 o un token importato.

# create a random, base64-encoded, 32-byte key material
$ KEY_MATERIAL=$(openssl rand -base64 32)

# create a root key from a base64-encoded value
$ ibmcloud kp key create my-base64-root-key -k $KEY_MATERIAL

Creating key: 'my-base64-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
e55f86ab-6984-4594-ad23-3024f6440a58   my-base64-root-key

# create a new key material
$ NEW_KEY_MATERIAL=$(openssl rand -base64 32)

# rotate the key
$ ibmcloud kp key rotate e55f86ab-6984-4594-ad23-3024f6440a58 -k $NEW_KEY_MATERIAL

Rotating root key...
OK

# the key was created from a key material, NOT providing a new key material will fail
$ ibmcloud kp key rotate e55f86ab-6984-4594-ad23-3024f6440a58

Rotating root key...
FAILED

Esempio 3

Questo esempio mostra come...

  1. Crea una chiave root

  2. Creare una chiave di crittografia dei dati (DEK), questo è il plaintext

  3. Impacchettando la DEK con la chiave root, viene creato un ciphertext

  4. Ruota la chiave root

  5. Annulla l'impacchettamento del testo cifrato per rivelare il DEK originale (testo in chiaro) e un nuovo testo cifrato (il nuovo testo cifrato è il testo in chiaro racchiuso con la nuova chiave root ruotata)

  6. Spacchetta il nuovo testo cifrato per rivelare la DEK originale (testo in chiaro)

# create a root key
$ KEY_ID=$(ibmcloud kp key create my-root-key --output json | jq -r '.["id"]')

$ echo $KEY_ID

5b976173-7804-4f82-acfa-bb98098bc528

# create a random, base64-encoded, 32-byte data encryption key (DEK)
$ PLAINTEXT=$(openssl rand -base64 32)

$ echo $PLAINTEXT

UPJ4YDwbQMjQG/aqlHsPhHV1CBkpIXngLHFS5+i4UZ4=

# wrap the plaintext key with the root key, creating a DEK (this is the ciphertext)
$ CIPHERTEXT=$(ibmcloud kp key wrap $KEY_ID -p $PLAINTEXT --output json | jq -r '.["Ciphertext"]')

$ echo $CIPHERTEXT

eyJjaXBoZXJ0ZXh0IjoiQkFrTlJrS2Q0 ...<redacted>... ODA5OGJjNTI4In0=

# rotate the root key
$ ibmcloud kp key rotate $KEY_ID

Rotating root key...
OK

# show key details
$ ibmcloud kp key show $KEY_ID --output json

{
    "id": "5b976173-7804-4f82-acfa-bb98098bc528",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-10T18:09:27Z",
    "lastUpdateDate": "2020-06-10T18:13:31Z",
    "lastRotateDate": "2020-06-10T18:13:31Z",
    "keyVersion": {
        "id": "4330715a-918b-4718-b5ca-9475a214067e",
    "creationDate": "2020-06-10T18:13:31Z"
    },
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:5b976173-7804-4f82-acfa-bb98098bc528"
}

# unwrap the ciphertext, reveal the original DEK (plaintext),
# and see the new ciphertext (the plaintext wrapped with the rotated root key)
$ ibmcloud kp key unwrap $KEY_ID $CIPHERTEXT --output json

{
    "Plaintext": "UPJ4YDwbQMjQG/aqlHsPhHV1CBkpIXngLHFS5+i4UZ4=",
    "Rewrapped Plaintext": "eyJjaXBoZXJ0ZXh0IjoiS0FITEFRWjdh ...<redacted>... NWEyMTQwNjdlIn0="
}

# capture the new (rewrapped) plaintext
$ NEWCIPHERTEXT=eyJjaXBoZXJ0ZXh0IjoiS0FITEFRWjdh ...<redacted>... NWEyMTQwNjdlIn0=

# unwrap the ciphertext and reveal the original DEK (plaintext)
$ ibmcloud kp key unwrap $KEY_ID $NEWCIPHERTEXT --output json

{
    "Plaintext": "UPJ4YDwbQMjQG/aqlHsPhHV1CBkpIXngLHFS5+i4UZ4=",
    "Rewrapped Plaintext": ""
}

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o l'alias v4 della chiave root che vuoi ruotare.

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -k, --key-material

    Per ruotare una chiave inizialmente generata senza un parametro --key-material, ovvero kp key create my-key, omettere il parametro --key-material.

    Se è stata creata una chiave con il parametro --key-material, specifica il nuovo materiale della chiave base64-encoded che utilizzi per ruotare una chiave root esistente.

    Per ruotare una chiave inizialmente importata nel servizio, fornire una nuova chiave da 32 byte (256 bit).

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

pianificazione chiave kp - eliminazione

Una chiave con una politica dual-auth-delete richiede l'autorizzazione di due utenti di gestione per eliminare la chiave.

Seguire questo processo per eliminare una chiave con una normativa dual-auth-delete.

  1. Creare una chiave e abilitare la politica dual-auth-delete

  2. L'utente 1 pianifica (autorizza) l'eliminazione di una chiave con kp key schedule-delete comando

  3. L'utente 2 pianifica (autorizza) l'eliminazione di una chiave

  4. La chiave viene eliminata dopo l'esecuzione del secondo schedule-delete, che è supportato nell'interfaccia utente, API e CLI

  5. Se una seconda autorizzazione non si verifica entro 7 giorni, la chiave ritorna allo stato predefinito

Esistono due modi per abilitare la politica dual-auth-delete:

  • Impostare la politica per una singola chiave utilizzando kp key policy-update dual-auth-delete
  • Impostare la politica per l'istanza utilizzando kp instance policy-update dual-auth-delete; tutte le chiavi create dopo l'abilitazione della politica dell'istanza ereditano l'impostazione della politica dell'istanza

Il Il comando kp key cancel - delete annulla o rimuove un'autorizzazione precedente.

ibmcloud kp key schedule-delete KEY_ID_OR_ALIAS
    -i, --instance-id INSTANCE_ID
    [--key-ring         KEY_RING_ID]

Esempio

Questo è un esempio di pianificazione di una chiave da eliminare.

# schedule this key to be deleted
$ ibmcloud kp key schedule-delete $KEY_ID_OR_ALIAS

Scheduling key for deletion...
OK

# this key has a dual-auth-delete policy
$ ibmcloud kp key policies $KEY_ID_OR_ALIAS --output json

[
  {
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-06-22T19:13:00Z",
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:a192d603-0b8d-452f-aac3-f9e1f95e7411:policy:2427dbde-6cff-41eb-8b5a-ff26b038cafc",
    "lastUpdateDate": "2020-06-22T21:36:16Z",
    "updatedBy": "user id ...<redacted>...",
    "dualAuthDelete": { "enabled": true
    }
  }
]

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o alias v4 della chiave che vuoi eliminare. Per visualizzare l'elenco delle chiavi disponibili, esegui il comando kp keys.

Parametri facoltativi

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

mostra chiave kp

Richiama i dettagli su una chiave, come ad esempio i metadati o il materiale della chiave.

Se la chiave è stata progettata come una chiave root, il sistema non può restituire il materiale della chiave per tale chiave.

ibmcloud kp key show KEY_ID_OR_ALIAS
        -i, --instance-id INSTANCE_ID
    [--key-ring          KEY_RING_ID]
    [-o, --output      OUTPUT]

Esempi

Questi sono esempi di kp key show.

Esempio 1

Crea una chiave root e mostra i dettagli.

# create a root key
$ ibmcloud kp key create my-root-key

Creating key: 'my-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
8635b804-9966-4918-a16b-d561fdbf181f   my-root-key

# show key details
$ ibmcloud kp key show 8635b804-9966-4918-a16b-d561fdbf181f

Grabbing info for key id: 8635b804-9966-4918-a16b-d561fdbf181f...
OK
Key ID                                 Key Name      Description   Creation Date                   Expiration Date
8635b804-9966-4918-a16b-d561fdbf181f   my-root-key                 2020-05-05 19:58:02 +0000 UTC   Key does not expire

Esempio 2

Questa è una spiegazione dei valori e delle chiavi JSON da kp key show . In questo esempio, la chiave è stata ruotata per garantire che vengano visualizzate tutte le coppie chiave / valore JSON.

$ ibmcloud kp key show 8635b804-9966-4918-a16b-d561fdbf181f --output json

{
    "id": "8635b804-9966-4918-a16b-d561fdbf181f",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-05-05T19:58:02Z",
    "lastUpdateDate": "2020-05-05T19:58:24Z",
    "lastRotateDate": "2020-05-05T19:58:24Z",
    "keyVersion": {
        "id": "85b65b20-4165-4da3-8ba9-880e72390461",
        "creationDate": "2020-05-05T19:58:24Z"
    },
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:8635b804-9966-4918-a16b-d561fdbf181f"
}
Chiave Descrizione
id Questo è il KEY_ID, è univoco e viene utilizzato ogni volta che la CLI specifica un KEY_ID
nome Il nome fornito quando è stata creata la chiave
Immettere Utilizzato dall'API per impostare il tipo di contenuto in una chiamata REST
algorithmType I tipi di algoritmo sono AES (advanced encryption standard) o CBC (cipher block chaining)
createdBy L'id utente che ha creato la chiave
creationDate Data e ora di creazione della chiave
lastUpdateDate Data e ora dell'ultimo aggiornamento della chiave
lastRotateDate Data e ora dell'ultima rotazione della chiave; questa voce esiste solo se la chiave è stata ruotata
keyVersion / id Identifica la versione più recente della chiave root
keyVersion / creationDate Data e ora dell'ultimo aggiornamento del materiale della chiave
estraibile Un valore booleano che determina se il materiale crittografico può uscire dal servizio. Se impostato su false, Key Protect designa la chiave come chiave root non estraibile utilizzata per le azioni di impacchettamento e spacchettamento. Se impostato su true, Key Protect designa la chiave come chiave standard che puoi archiviare nelle tue applicazioni e servizi. Una volta impostato su false, non può essere modificato in true.
stato 1 - la chiave è attiva; 2 - la chiave è sospesa; consultare stati chiave
CRN Il nome della risorsa cloud (CRN)

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o l'alias v4 della chiave root che vuoi mostrare.

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

sincronizzazione chiave kp

Questo sottocomando sincronizza le risorse associate per una chiave.

ibmcloud kp key sync KEY_ID
     -i, --instance-id INSTANCE_ID
    [--key-ring             KEY_RING_ID]
    [-o, --output      FORMAT]

Esempi

Questo è un esempio di kp key sync.

Esempio

Sincronizza una chiave e mostra i risultati.

# synchronize the associated resources for a given key
$ ibmcloud kp key sync 94c06f9c-a07a-4961-8548-553cf7431f18

Synchronizing key...
OK
Key's associated resources are synchronized successfully

Parametri obbligatori

  • KEY_ID

    L'ID della chiave che si desidera sincronizzare.

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

aggiornamento chiave kp

Aggiorna una chiave con un file di chiavi esistente o un nuovo file di chiavi nel tuo Istanza Key Protect.

ibmcloud kp key update KEY_ID_OR_ALIAS
        -i, --instance-id         INSTANCE_ID
        -r, --new-key-ring        KEY_RING_ID
    [-o, --output              OUTPUT]

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o l'alias v4 della chiave root che vuoi mostrare.

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

  • -r, --new-key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

Parametri facoltativi

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

Esempi

Si noti che il keyring deve essere già stato creato, come parte della creazione di una chiave o da solo.

Questo è un esempio di kp key update.

ic kp key update 5f2cc155-fe16-492c-845c-4d1f0688c7ba -r TestRing

L'esecuzione del comando ha un risultato tipico:

Updating key...
OK
Key ID                                 Key Name             Key Ring ID   
5f2cc155-fe16-492c-845c-4d1f0688c7ba   TestKey                           TestRing   

chiave kp non impacchettata

Decifrare una chiave di crittografia dei dati utilizzando una chiave principale memorizzata nel proprio Istanza Key Protect.

ibmcloud kp key unwrap KEY_ID_OR_ALIAS CIPHERTEXT_FROM_WRAP
        -i, --instance-id INSTANCE_ID
    [-a, --aad         ADDITIONAL_DATA]
    [--key-ring           KEY_RING_ID]
    [-o, --output      OUTPUT]

Esempi

Questi sono esempi di kp key unwrap.

Esempio 1

Annulla il wrapping di un testo crittografato per rivelare la chiave di crittografia dei dati in testo semplice (DEK).

# create a root key
$ ibmcloud kp key create my-root-key

Creating key: 'my-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
807eb0a6-cc10-4bfe-8331-41a6f712c4ea   my-root-key

# create a data encryption key (DEK), wrapped with the root key
$ ibmcloud kp key wrap 807eb0a6-cc10-4bfe-8331-41a6f712c4ea

Wrapping key...
OK
Ciphertext
eyJjaXBoZXJ0ZXh0IjoiKzhjbHVqcUNP ...<redacted>... NmY3MTJjNGViIn0=

# capture the ciphertext
$ CIPHERTEXT=eyJjaXBoZXJ0ZXh0IjoiKzhjbHVqcUNP ...<redacted>... NmY3MTJjNGViIn0=

# unwrap the ciphertext to reveal the plaintext data encryption key (DEK)
$ ibmcloud kp key unwrap 807eb0a6-cc10-4bfe-8331-41a6f712c4ea $CIPHERTEXT

Unwrapping key...
OK
Plaintext                                      Rewrapped Plaintext
mXW4GmBhkRG1+Dzkx1D6dMX99a4KyYwtwbghaaLEQZ0=

Esempio 2

Spacchetta un testo cifrato e fornisci informazioni AAD.

Un caso d'uso per fornire ulteriori dati di autenticazione (AAD) è quello di "proteggere con password" il testo cifrato per rendere più difficile lo spacchettamento.

Il testo cifrato e l'AAD sono necessari per spacchettare il testo cifrato e rivelare la chiave di crittografia dei dati in testo semplice (DEK).

# create a root key
$ KEY_ID=$(ibmcloud kp key create my-root-key --output json | jq -r '.["id"]')

$ echo $KEY_ID

5f2cc155-fe16-492c-845c-4d1f0688c7ba

# create a random, base64-encoded, 32-byte data encryption key (DEK)
$ PLAINTEXT=$(openssl rand -base64 32)

$ echo $PLAINTEXT

H4ZfQe66aKcxirfCdNZ/3Na0JECP6HsAM3yclKmIfPQ=

# set the additional authentication data (AAD)
$ AAD1=My-Secret-Password
$ AAD2=My-Verification-Phrase

# wrap the plaintext with the root key and AAD
$ CIPHERTEXT=$(ibmcloud kp key wrap $KEY_ID -a "$AAD1,$AAD2" -p $PLAINTEXT --output json | jq -r '.["Ciphertext"]')

$ echo $CIPHERTEXT

eyJjaXBoZXJ0ZXh0IjoiL1pQUzRLbUxQ ...<redacted>... ZjA2ODhjN2JiIn0=

# unwrap the ciphertext and reveal the original plaintext DEK
$ ibmcloud kp key unwrap $KEY_ID $CIPHERTEXT -a $AAD1,$AAD2

Unwrapping key...
OK
Plaintext                                      Rewrapped Plaintext
H4ZfQe66aKcxirfCdNZ/3Na0JECP6HsAM3yclKmIfPQ=

# this should fail (missing some of the AAD)
$ ibmcloud kp key unwrap $KEY_ID $CIPHERTEXT -a $AAD1

Unwrapping key...
FAILED

# this should fail (AAD is in a different order)
$ ibmcloud kp key unwrap $KEY_ID $CIPHERTEXT -a $AAD2,$AAD1

Unwrapping key...
FAILED

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o l'alias v4 della chiave principale utilizzata per la richiesta di wrap iniziale.

  • CIPHERTEXT_FROM_WRAP

    La chiave di dati crittografata restituita durante l'operazione di impacchettamento iniziale.

  • -i, --instance-ID

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -a, --aad

    Gli ulteriori dati di autenticazione (o AAD, additional authentication data) che erano stati utilizzati per proteggere ulteriormente una chiave. Puoi fornire fino a 255 stringhe, ciascuna delimitata da una virgola. Se hai fornito l'AAD durante il wrap, devi specificare lo stesso AAD, nello stesso ordine, durante l'unwrap.

    Il servizio Key Protect non salva dati di autenticazione aggiuntivi. Se fornisci un AAD, salva i dati in un luogo sicuro per assicurarti di poter accedere e fornire lo stesso AAD durante le seguenti richieste di spacchettamento.

-o, --output

Set the CLI output format. By default, all commands print in table format. To change the output format to JSON, use `--output json`.
  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

Versioni chiave kp

Quando si ruota una chiave root, Key Protect crea una nuova versione della chiave. Elenca tutte le versioni chiave disponibili per un KeyID o un alias chiave nella tua istanza Key Protect.

ibmcloud kp key versions KEY_ID_OR_ALIAS
        -i, --instance-id INSTANCE_ID
    [-r, --key-ring                KEY_RING_ID]
    [-n, --number-of-key-versions  VERSION_LIMIT]
    [-o, --output                  OUTPUT]
    [-s, --starting-offset         OFFSET]
    [-t, --total-count             TOTAL_COUNT]
    [-a, --all-key-states          ALL_KEY_STATES]

Esempi

Questi sono esempi di kp key versions.

Esempio 1

Un caso di utilizzo è il controllo della cronologia di rotazione di una chiave root come amministratore della sicurezza, visualizzandone la cronologia della versione della chiave.

# create a root key
$ ibmcloud kp key create my-root-key

Creating key: 'my-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
807eb0a6-cc10-4bfe-8331-41a6f712c4ea   my-root-key

# rotate the root key
$ ibmcloud kp key rotate 807eb0a6-cc10-4bfe-8331-41a6f712c4ea

Rotating root key...
OK

# Inspect the versions
$ ibmcloud kp key versions 807eb0a6-cc10-4bfe-8331-41a6f712c4ea

Retrieving key Versions...
OK
Key Version ID                         Creation Date   
21562e93-8882-420e-90a7-912c70023373   2022-07-08T17:02:10Z
390086ac-76fa-4094-8cf3-c0829bd69526   2022-07-08T17:02:40Z

Esempio 2

Lo stesso caso di utilizzo per il controllo di una chiave root come amministratore della sicurezza e la visualizzazione della cronologia, con il relativo conteggio totale nell'output JSON.

# create a root key
$ ibmcloud kp key create my-root-key

Creating key: 'my-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
807eb0a6-cc10-4bfe-8331-41a6f712c4ea   my-root-key

# rotate the root key
$ ibmcloud kp key rotate 807eb0a6-cc10-4bfe-8331-41a6f712c4ea

Rotating root key...
OK

# Inspect the versions
$ ibmcloud kp key versions 807eb0a6-cc10-4bfe-8331-41a6f712c4ea -t -o json
{
        "metadata": {
                "collectionType": "application/vnd.ibm.kms.key.version+json",
                "collectionTotal": 2,
                "totalCount": 2
        },
        "resources": [
                {
                        "id": "21562e93-8882-420e-90a7-912c70023373",
                        "creationDate": "2022-07-08T17:02:10Z"
                },
                {
                        "id": "390086ac-76fa-4094-8cf3-c0829bd69526",
                        "creationDate": "2022-07-08T17:02:40Z"
                }
        ]
}

Esempio 3

Un altro caso d'uso elenca le prime 12 versioni di chiave per una serie di chiavi su una rotazione mensile per l'ultimo anno.

# create a root key
$ ibmcloud kp key create my-root-key

Creating key: 'my-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
807eb0a6-cc10-4bfe-8331-41a6f712c4ea   my-root-key

# rotate the root key
$ ibmcloud kp key rotate 807eb0a6-cc10-4bfe-8331-41a6f712c4ea

Rotating root key...
OK

# Inspect the versions
$ ibmcloud kp key versions 807eb0a6-cc10-4bfe-8331-41a6f712c4ea -n 12 -o json
{
        "metadata": {
                "collectionType": "application/vnd.ibm.kms.key.version+json",
                "collectionTotal": 12
        },
        "resources": [
                {
                        "id": "21562e93-8882-420e-90a7-912c70023373",
                        "creationDate": "2021-07-08T17:02:10Z"
                },
                {
                        "id": "390086ac-76fa-4094-8cf3-c0829bd69526",
                        "creationDate": "2021-08-08T17:02:40Z"
                },[...10x]
        ]
}

Esempio 4

Un altro caso di utilizzo elenca le seconde 12 versioni di chiave per una serie di chiavi su una rotazione mensile negli ultimi due anni.

ibmcloud kp versioni chiave $KEY_ID_OR_ALIAS -n 12 -s 12

# create a root key
$ ibmcloud kp key create my-root-key

Creating key: 'my-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
807eb0a6-cc10-4bfe-8331-41a6f712c4ea   my-root-key

# rotate the root key
$ ibmcloud kp key rotate 807eb0a6-cc10-4bfe-8331-41a6f712c4ea

Rotating root key...
OK

# Inspect the versions
$ ibmcloud kp key versions 807eb0a6-cc10-4bfe-8331-41a6f712c4ea -n 12 -s 12 -o json
{
        "metadata": {
                "collectionType": "application/vnd.ibm.kms.key.version+json",
                "collectionTotal": 12
        },
        "resources": [
                {
                        "id": "21562e93-8882-420e-90a7-912c70023373",
                        "creationDate": "2021-07-08T17:02:10Z"
                },
                {
                        "id": "390086ac-76fa-4094-8cf3-c0829bd69526",
                        "creationDate": "2021-08-08T17:02:40Z"
                },[...10x]
        ]
}

Esempio 5

Un indicatore facoltativo per restituire il numero di versioni di una chiave che non è attualmente attiva. In precedenza, il comando avrebbe avuto esito negativo, come nel seguente esempio:

# Attempt to show version count
$ ibmcloud kp key versions af61298c-d75d-42a8-aa76-e04178cf4685 -i 99980ccc-d482-4cd0-bb41-deb4f7f1eb92 -t

Retrieving key Versions...
FAILED
KEY_ACTION_INVALID_STATE_ERR
Key is not in a valid state
Correlation-ID:a494bf49-be82-426f-88d8-17b58cc8634d

Con la versione CLI 0.8.0 e successive, il comando ha esito positivo quando si aggiunge l'indicatore -a, come nel seguente esempio:

# Attempt to show version count
$ ibmcloud kp key versions af61298c-d75d-42a8-aa76-e04178cf4685 -i 99980ccc-d482-4cd0-bb41-deb4f7f1eb92 -t -a

Retrieving key Versions...
OK
TotalCount: 2
Key Version ID                         Creation Date
14dfde20-a751-4c3e-b6b0-e8d00a17d8d1   2023-06-22T15:16:09Z
af61298c-d75d-42a8-aa76-e04178cf4685   2023-06-22T15:10:28Z

Si noti che se l'indicatore -a non viene fornito, KEY_ACTION_INVALID_STATE_ERR viene ancora restituito per una chiave in uno stato diverso da attivo.

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o l'alias v4 della chiave principale utilizzata per la richiesta di wrap iniziale.

  • -i, --instance-ID

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

  • -n --number-of-key-versions

    Limita il numero di versioni chiave che devono essere richiamate dal valore intero fornito (valore predefinito: 200).

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

  • -s --starting-offset

    Richiama le versioni della chiave dall'offset come specificato dal valore intero fornito.

  • -t --total-count

    Utilizzato per ripristinare il numero totale di versioni chiave per una chiave in base al valore intero fornito.

  • -a --all-key-states

    Un indicatore facoltativo per restituire il numero di versioni per tutti gli stati chiave, incluse le chiavi non attive.

impacchettamento chiave kp

Esegui il wrapping di una chiave di crittografia dei dati (DEK) utilizzando una chiave root memorizzata nel Istanza Key Protect. Una DEK viene tipicamente utilizzata per crittografare "altre" informazioni.

Quando impacchettate una DEK con una chiave root, Key Protect combina la potenza di più algoritmi per proteggere la privacy e l'integrità dei tuoi dati crittografati.

Non puoi impacchettare una chiave standard, ovvero una chiave creata utilizzando -s parametro (ibmcloud kp key create my-key-name -s).

ibmcloud kp key wrap KEY_ID_OR_ALIAS
        -i, --instance-id INSTANCE_ID
    [--key-ring           KEY_RING_ID]
    [-a, --aad         ADDITIONAL_DATA]
    [-o, --output      OUTPUT]
    [-p, --plaintext   DATA_KEY]

Procedure consigliate

Il wrapping di una chiave di crittografia dei dati (DEK) crea un ciphertext. Il testo cifrato è un'informazione crittografata che, una volta decodificata, rivela la DEK originale.

Il servizio Key Protect non memorizza la tua DEK. Salva o conserva nell'archiviazione il testo cifrato per assicurarti di poter richiamare la DEK con il comando kp key unwrap.

Si consiglia di non salvare mai, o di non conservare nell'archiviazione, la DEK in testo semplice. Nella tua applicazione, carica il testo cifrato dalla memoria, chiama Key Protect per ottenere la DEK in testo semplice e utilizzare la DEK per crittografare o impacchettare "altre" informazioni.

Non salvare la DEK nell'archiviazione persistente. Esporre la DEK può consentire ad altri di decodificare i tuoi dati.

Un nuovo testo cifrato viene creato ogni volta che la chiave root viene impacchettata.

Esempi

Questi sono esempi di kp key wrap.

Esempio 1

Key Protect crea una nuova chiave di crittografia dei dati (DEK) base64-encoded e la racchiude con la chiave root.

# create a root key
$ ibmcloud kp key create my-root-key

Creating key: 'my-root-key', in instance: '390086ac-76fa-4094-8cf3-c0829bd69526'...
OK
Key ID                                 Key Name
807eb0a6-cc10-4bfe-8331-41a6f712c4ea   my-root-key

# create a new key and wrap it with the root key, creating a DEK (this is the ciphertext)
$ ibmcloud kp key wrap 807eb0a6-cc10-4bfe-8331-41a6f712c4ea

Wrapping key...
OK
Ciphertext
eyJjaXBoZXJ0ZXh0IjoiKzhjbHVqcUNP ...<redacted>... NmY3MTJjNGViIn0=

# capture the ciphertext
$ CIPHERTEXT=eyJjaXBoZXJ0ZXh0IjoiKzhjbHVqcUNP ...<redacted>... NmY3MTJjNGViIn0=

# unwrap the ciphertext to reveal the plaintext (DEK)
$ ibmcloud kp key unwrap 807eb0a6-cc10-4bfe-8331-41a6f712c4ea $CIPHERTEXT

Unwrapping key...
OK
Plaintext                                      Rewrapped Plaintext
mXW4GmBhkRG1+Dzkx1D6dMX99a4KyYwtwbghaaLEQZ0=

Esempio 2

Genera una chiave di crittografia dei dati (DEK) base64-encoded e impacchettarla con la chiave root.

# create a root key
$ KEY_ID=$(ibmcloud kp key create my-root-key --output json | jq -r '.["id"]')

$ echo $KEY_ID

9052d914-bebe-4177-90e9-6073a167b507

# create a random, base64-encoded, 32-byte data encryption key (DEK)
$ PLAINTEXT=$(openssl rand -base64 32)

$ echo $PLAINTEXT

tEqoiCu9CeUsbqRe6yBUkrJg80QKKG/z46OkX0YQMV8=

# wrap the plaintext key with the root key, creating a DEK (this is the ciphertext)
$ CIPHERTEXT=$(ibmcloud kp key wrap $KEY_ID -p $PLAINTEXT --output json | jq -r '.["Ciphertext"]')

$ echo $CIPHERTEXT

eyJjaXBoZXJ0ZXh0IjoiTkdQRlhCb1dT ...<redacted>... M2ExNjdiNTA3In0=

# unwrap the ciphertext and reveal the original DEK
$ ibmcloud kp key unwrap $KEY_ID $CIPHERTEXT

tEqoiCu9CeUsbqRe6yBUkrJg80QKKG/z46OkX0YQMV8=

Esempio 3

Impacchettare una chiave root e fornire le informazioni AAD.

Un caso di utilizzo per fornire ulteriori dati di autenticazione (AAD) è quello di "proteggere con password" e aggiungere una "frase di verifica" al testo cifrato, il che rende più difficile lo spacchettamento.

Il testo cifrato e l'AAD sono necessari per spacchettare il testo cifrato e rivelare il testo in chiaro DEK.

# create a root key
$ KEY_ID=$(ibmcloud kp key create my-root-key --output json | jq -r '.["id"]')

$ echo $KEY_ID

5f2cc155-fe16-492c-845c-4d1f0688c7ba

# set the additional authentication data (AAD)
$ AAD1=My-Secret-Password
$ AAD2=My-Verification-Phrase

# wrap the plaintext DEK with the root key and AAD
$ CIPHERTEXT=$(ibmcloud kp key wrap $KEY_ID -a "$AAD1,$AAD2" --output json | jq -r '.["Ciphertext"]')

$ echo $CIPHERTEXT

eyJjaXBoZXJ0ZXh0IjoiL1pQUzRLbUxQ ...<redacted>... ZjA2ODhjN2JiIn0=

# unwrap the ciphertext and reveal the original DEK
$ ibmcloud kp key unwrap $KEY_ID $CIPHERTEXT -a $AAD1,$AAD2

Unwrapping key...
OK
Plaintext                                      Rewrapped Plaintext
H4ZfQe66aKcxirfCdNZ/3Na0JECP6HsAM3yclKmIfPQ=

# this should fail (missing some of the AAD)
$ ibmcloud kp key unwrap $KEY_ID $CIPHERTEXT -a $AAD1

Unwrapping key...
FAILED

# this should fail (AAD is in a different order)
$ ibmcloud kp key unwrap $KEY_ID $CIPHERTEXT -a $AAD2,$AAD1

Unwrapping key...
FAILED

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o l'alias v4 della chiave radice che si desidera utilizzare per il wrapping. Non è possibile impacchettare una chiave standard.

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -a, --aad

    Gli ulteriori dati di autenticazione (o AAD, additional authentication data) che vengono utilizzati per proteggere ulteriormente una chiave. L'AAD è un array di stringhe che verifica l'integrità del contenuto della chiave. Ogni stringa può contenere fino a 255 caratteri.

    Se si fornisce un AAD durante una richiesta di “wrap”, è necessario specificare lo stesso AAD, nello stesso ordine, durante la successiva richiesta di “unwrap”.

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

  • -p, --plaintext

    plaintext specifica una chiave di crittografia dei dati (DEK) base64-encoded che viene impacchettata dalla chiave root (identificata dai parametri KEY_ID o ALIAS ).

    La chiave di crittografia dei dati (DEK) di base64-encoded che si desidera gestire e proteggere. Per importare una chiave esistente, fornire una chiave da 32 byte (256 bit).

    Per generare e incapsulare un nuovo DEK, ometti il parametro --plaintext .

  • --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

chiavi kp

Elenca le chiavi disponibili nella tua istanza di Key Protect.

Le chiavi sono elencate in ordine key id ; consultare esempio 5.

ibmcloud kp keys
        -i, --instance-id      INSTANCE_ID
        [-b --sort-by          SORT_BY]
        [-c, --crn]
        [-f, --key-filter      FILTERS]
        [--key-ring            KEY_RING_ID]
        [--key-states          STATES]
        [-l --key-search       KEY_SEARCH]
        [-n, --number-of-keys  NUMBER_OF_KEYS]
        [-o, --output          OUTPUT]
        [-s, --starting-offset STARTING_OFFSET]
        [-t, --key-type        TYPE]

Esempi

Questi sono esempi di kp keys.

Esempio 1

Elenca le chiavi. Tieni presente che questo elencherà solo le prime 200 chiavi nella tua istanza per default. Per visualizzare un numero maggiore o minore di chiavi, fornire un valore per il parametro --number-of-keys.

# list keys
$ ibmcloud kp keys

Retrieving keys...
OK
Key ID                                 Key Name
5f2cc155-fe16-492c-845c-4d1f0688c7ba   my-root-key
c36e9f3a-feaf-4033-8603-687784dc7e51   my-root-key

Esempio 2

Elencare le chiavi e mostrare il CRN (cloud resource name) utilizzando --crn parametro.

# list keys and show the cloud resource name (CRN)
$ ibmcloud kp keys -c

Retrieving keys...
OK
Key ID                                 Key Name      CRN
5f2cc155-fe16-492c-845c-4d1f0688c7ba   my-root-key   crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:5f2cc155-fe16-492c-845c-4d1f0688c7ba
c36e9f3a-feaf-4033-8603-687784dc7e51   my-root-key   crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:c36e9f3a-feaf-4033-8603-687784dc7e51

Esempio 3

Elenca le chiavi in formato JSON.

Il parametro --output json implica --crn (nome risorsa cloud) parametro.

# list keys
$ ibmcloud kp keys --output json

[
  {
    "id": "5f2cc155-fe16-492c-845c-4d1f0688c7ba",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-05-10T18:04:01Z",
    "lastUpdateDate": "2020-05-10T18:04:01Z",
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:5f2cc155-fe16-492c-845c-4d1f0688c7ba"
    },
    {
        "id": "c36e9f3a-feaf-4033-8603-687784dc7e51",
    "name": "my-root-key",
    "type": "application/vnd.ibm.kms.key+json",
    "algorithmType": "AES",
    "createdBy": "user id ...<redacted>...",
    "creationDate": "2020-05-10T17:56:37Z",
    "lastUpdateDate": "2020-05-10T17:56:37Z",
    "extractable": false,
    "state": 1,
    "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:390086ac-76fa-4094-8cf3-c0829bd69526:key:c36e9f3a-feaf-4033-8603-687784dc7e51"
  }
]

Esempio 4

Elencare le chiavi e iterarle, mostrando i dettagli.

# list keys and convert to a list
$ KEYS=$(ibmcloud kp keys --output json | jq -r '.[] | .id')

$ for key in $(echo "${KEYS}"); do
    ibmcloud kp key show ${key}
done

Grabbing info for key id: 5f2cc155-fe16-492c-845c-4d1f0688c7ba...
OK
Key ID                                 Key Name      Description   Creation Date                   Expiration Date
5f2cc155-fe16-492c-845c-4d1f0688c7ba   my-root-key                 2020-05-10 18:04:01 +0000 UTC   Key does not expire

Grabbing info for key id: c36e9f3a-feaf-4033-8603-687784dc7e51...
OK
Key ID                                 Key Name      Description   Creation Date                   Expiration Date
c36e9f3a-feaf-4033-8603-687784dc7e51   my-root-key                 2020-05-10 17:56:37 +0000 UTC   Key does not expire

Esempio 5

Creare 20 chiavi e visualizzarle in gruppi di 5 utilizzando le opzioni kp keys -n -s.

# create 20 test keys
$ for I in {1..20}; do
    KEY_ID=$(ibmcloud kp key create my-test-key-$I --output json | jq -r '.["id"]')
    KEY_NAME=$(ibmcloud kp key show $KEY_ID --output json | jq -r '.["name"]')
    echo $KEY_ID $KEY_NAME
done

b70f62a1-4d52-4526-91a9-ce47bf14c2a5 my-test-key-1
215f592c-3e42-47b6-867c-3cc1cce8a8fd my-test-key-2
df530c55-39c0-44e8-b7db-397593f70d90 my-test-key-3
768c9ceb-368b-46f7-9b1d-be211e036fe1 my-test-key-4
f141be88-5a34-4290-8513-4f01d934e75a my-test-key-5
b8794334-eea6-4c0d-8fe1-8086300b13f7 my-test-key-6
87679194-52d0-42af-81e1-bffd64f87315 my-test-key-7
cc7faf46-43cf-43b2-be98-7d1815371639 my-test-key-8
e9b08526-3227-406c-b83f-c28844bd952b my-test-key-9
3ee0d859-2968-4444-8e4d-3d28614f055c my-test-key-10
bc459a2f-56cb-445e-b4ee-9d1866b57560 my-test-key-11
62090ba8-7363-408e-9edc-aa9fb69c09be my-test-key-12
3b4b0511-00df-48e6-ad65-fad35bb6ce17 my-test-key-13
16276369-ba81-4eb5-be92-f13512147ad4 my-test-key-14
3d683d56-d340-40cb-b8b6-605dcfded01f my-test-key-15
10954149-0217-472d-8137-42fc330dbd03 my-test-key-16
54dd2745-7718-487f-85e6-a67e758dd945 my-test-key-17
3a5a3b52-6942-463d-9f7a-5b216bbf5123 my-test-key-18
90138be5-1dd1-4eea-b7c1-73cc8609e7f7 my-test-key-19
cf0a3d8b-4856-4aa5-be6a-88cca465eab0 my-test-key-20

# this is the same list sorted in KEY_ID order
# this is the order we expect when listing keys

10954149-0217-472d-8137-42fc330dbd03 my-test-key-16
16276369-ba81-4eb5-be92-f13512147ad4 my-test-key-14
215f592c-3e42-47b6-867c-3cc1cce8a8fd my-test-key-2
3a5a3b52-6942-463d-9f7a-5b216bbf5123 my-test-key-18
3b4b0511-00df-48e6-ad65-fad35bb6ce17 my-test-key-13

3d683d56-d340-40cb-b8b6-605dcfded01f my-test-key-15
3ee0d859-2968-4444-8e4d-3d28614f055c my-test-key-10
54dd2745-7718-487f-85e6-a67e758dd945 my-test-key-17
62090ba8-7363-408e-9edc-aa9fb69c09be my-test-key-12
768c9ceb-368b-46f7-9b1d-be211e036fe1 my-test-key-4

87679194-52d0-42af-81e1-bffd64f87315 my-test-key-7
90138be5-1dd1-4eea-b7c1-73cc8609e7f7 my-test-key-19
b70f62a1-4d52-4526-91a9-ce47bf14c2a5 my-test-key-1
b8794334-eea6-4c0d-8fe1-8086300b13f7 my-test-key-6
bc459a2f-56cb-445e-b4ee-9d1866b57560 my-test-key-11

cc7faf46-43cf-43b2-be98-7d1815371639 my-test-key-8
cf0a3d8b-4856-4aa5-be6a-88cca465eab0 my-test-key-20
df530c55-39c0-44e8-b7db-397593f70d90 my-test-key-3
e9b08526-3227-406c-b83f-c28844bd952b my-test-key-9
f141be88-5a34-4290-8513-4f01d934e75a my-test-key-5

# define a function for listing keys
$ list_keys () {
    N=$1
    S=$2
    KEYS=$(ibmcloud kp keys --number-of-keys $N --starting-offset $S --output json | jq -r '.[] | .id')
    for KEY_ID in $(echo "${KEYS}"); do
        KEY_ID=$(ibmcloud kp key show $KEY_ID --output json | jq -r '.["id"]')
    KEY_NAME=$(ibmcloud kp key show $KEY_ID --output json | jq -r '.["name"]')
    echo $KEY_ID $KEY_NAME
    done
}

# list the first group of keys
$ list_keys 5 0

10954149-0217-472d-8137-42fc330dbd03 my-test-key-16
16276369-ba81-4eb5-be92-f13512147ad4 my-test-key-14
215f592c-3e42-47b6-867c-3cc1cce8a8fd my-test-key-2
3a5a3b52-6942-463d-9f7a-5b216bbf5123 my-test-key-18
3b4b0511-00df-48e6-ad65-fad35bb6ce17 my-test-key-13

# list the second group of keys
$ list_keys 5 5

3d683d56-d340-40cb-b8b6-605dcfded01f my-test-key-15
3ee0d859-2968-4444-8e4d-3d28614f055c my-test-key-10
54dd2745-7718-487f-85e6-a67e758dd945 my-test-key-17
62090ba8-7363-408e-9edc-aa9fb69c09be my-test-key-12
768c9ceb-368b-46f7-9b1d-be211e036fe1 my-test-key-4

# list the third group of keys
$ list_keys 5 10

87679194-52d0-42af-81e1-bffd64f87315 my-test-key-7
90138be5-1dd1-4eea-b7c1-73cc8609e7f7 my-test-key-19
b70f62a1-4d52-4526-91a9-ce47bf14c2a5 my-test-key-1
b8794334-eea6-4c0d-8fe1-8086300b13f7 my-test-key-6
bc459a2f-56cb-445e-b4ee-9d1866b57560 my-test-key-11

# list the last group of keys
$ list_keys 5 15

cc7faf46-43cf-43b2-be98-7d1815371639 my-test-key-8
cf0a3d8b-4856-4aa5-be6a-88cca465eab0 my-test-key-20
df530c55-39c0-44e8-b7db-397593f70d90 my-test-key-3
e9b08526-3227-406c-b83f-c28844bd952b my-test-key-9
f141be88-5a34-4290-8513-4f01d934e75a my-test-key-5

# delete the test keys
$ KEYS=$(ibmcloud kp keys --output json | jq -r '.[] | .id')

$ for KEY_ID in $(echo "${KEYS}"); do
    KEY_NAME=$(ibmcloud kp key show $KEY_ID --output json | jq -r '.["name"]')
    if [[ $KEY_NAME == *"my-test-key-"* ]]; then
        echo "Deleting... $KEY_NAME $KEY_ID"
    ibmcloud kp key delete $KEY_ID
    fi
done

(output not shown)

Esempio 6

Elenca le chiavi in base agli stati chiave (Active, Suspended) nell'istanza Key Protect.

# list active and suspended keys
$ ibmcloud kp keys --key-states active,suspended

Retrieving keys...
OK
Key ID                                 Key Name
ef2cc155-fe56-492c-845c-4d1f0688c7ba   my-active-key
636e9f3a-feaf-4033-8603-687754dc7e51   my-suspended-key

Esempio 7

Elenca le chiavi in base al tipo di chiave (root) nell'istanza Key Protect.

# list root keys
$ ibmcloud kp keys -t root

Retrieving keys...
OK
Key ID                                 Key Name
2f1cb135-fa16-40dc-815c-4d1f0ee8c7ba   my-root-key

Esempio 8

Elenca le chiavi nell'istanza Key Protect con il nome chiave o l'alias che corrispondono esattamente ai caratteri nella stringa "TEST" senza virgolette.

# list keys with identifiers exactly matching TEST
$ ibmcloud kp keys -l exact:TEST

Retrieving keys...
OK
Key ID                                 Key Name
636e9f3a-feaf-4033-8603-687754dc7e51   TEST

Esempio 9

Elenca le chiavi nell'istanza Key Protect e ordina le chiavi in base al relativo ID e alla data in cui la chiave è stata creata a partire dal più recente (il trattino, '-', indica l'ordinamento decrescente).

# sort keys by id and descending creationDate
$ ibmcloud kp keys -b id,-creationDate

Retrieving keys...
OK
Key ID                                 Key Name
ef2cc155-fe56-492c-845c-4d1f0688c7ba   my-last-key
2f1cb135-fa16-40dc-815c-4d1f0ee8c7ba   my-first-key

Parametri obbligatori

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -b, --sort-by

    Ordinare le chiavi in base ai parametri. La proprietà predefinita per l'ordinamento dei risultati è "id." '-' prima del parametro indica l'ordinamento in ordine decrescente. I parametri di ordinamento supportati in questo momento sono:

    • id
    • stato
    • estraibile
    • importato
    • creationDate
    • lastUpdateDate
    • lastRotateDate
    • deletionDate
    • expirationDate
  • -c, --crn

    Includere il nome risorsa cloud (CRN) nell'output.

  • -f, --key-filter

    Filtrare le tasti in base ai parametri. I parametri di filtro chiave supportati sono

    • creationDate
    • deletionDate
    • expirationDate
    • estraibile
    • lastUpdateDate
    • lastRotateDate
    • stato

    Gli operatori di supporto per le date sono:

    • gt (maggiore di)
    • gte (maggiore o uguale a)
    • lt (minore di)
    • lte (minore o uguale a)

    I risultati saranno una corrispondenza esatta nel caso in cui uno di questi operatori sia mancante.

  • --key-states

    Lo stato delle chiavi da recuperare. Elenco di stringhe contenenti stati validi - Active, Suspended, Deactivated, Destroyed. (valore predefinito active,suspended,deactivated).

  • -l, --key-search

    Elencare le chiavi in base alla stringa di ricerca con qualificatori preceduti (ad esempio exact, not, alias, name). Per ulteriori dettagli, vedi la Documentazione API.

  • -n, --number-of-keys

    Limita il numero di chiavi da recuperare. Il valore predefinito è 200 e il massimo è 5000.

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

    L'impostazione dell'output su JSON (--output json) include il CRN (cloud resource name) nell'output.

  • -r, --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Obbligatorio se l'utente non dispone delle autorizzazioni sul keyring predefinito.

  • -s, --starting-offset

    Richiama le chiavi a partire dall'offset specificato. L'offset è basato su zero, il che significa che l'offset 0 (zero) è la prima chiave.

  • -t, --key-type

    Il tipo di chiavi da recuperare. Se impostato su standard-key, verranno richiamate le chiavi standard. Se impostato su root-key, verranno richiamate le chiavi root.

regione kp - set

Specifica un endpoint regionale Key Protect diverso.

ibmcloud kp region-set REGION
        -i, --instance-id INSTANCE_ID
        [-u, --unset]

Esempi

Questi sono esempi di kp region-set.

Esempio 1

Se il parametro REGION non viene specificato, viene richiesto di selezionare una regione.

# set the region endpoint
$ ibmcloud kp region-set

Select a Region:
1. au-syd
2. ca-tor
3. eu-de
4. eu-gb
5. jp-osa
6. jp-tok
7. us-east
8. us-south
9. br-sao
10. staging (us-south)
Enter a number:
5
OK

Esempio 2

Impostare la regione esplicitamente.

# set the region endpoint to "us-south"
$ ibmcloud kp region-set us-south

OK

Il REGION deve essere un endpoint regionale valido.

# this should fail (not a valid regional endpoint)
$ ibmcloud kp region-set not-a-region

FAILED

Esempio 3

Annullare l'impostazione (rimuovere) dell'endpoint regionale.

# remove the regional endpoint
$ ibmcloud kp region-set -u

OK

Parametri obbligatori

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • REGION

    Specificare un endpoint regionale. Questo parametro è facoltativo e, se non viene specificato, viene richiesto di selezionare un endpoint regionale da un elenco.

  • -u, --unset

    Annullare l'impostazione (rimuovere) dell'endpoint regionale.

registrazioni kp

Le registrazioni sono associazioni tra chiavi root e altre risorse cloud, come i bucket COS ( Cloud Object Storage ) o le distribuzioni Cloud Databases.

Ad esempio, in Key Protect crei una chiave root, utilizzata da COS per proteggere i dati inattivi.

La relazione tra altre risorse cloud e Key Protect è chiamato registration.

Non eliminare una chiave root se ci sono risorse, come bucket COS e oggetti, che si basano sulla chiave root. L'eliminazione della chiave root significa che non è possibile recuperare tali risorse. Questo è noto come "crypto shredding" e non c'è alcun recupero da questa azione.

ibmcloud kp registrations
        -i, --instance-id INSTANCE_ID
    [-r, --key-ring    KEY_RING_ID]
    [-c, --crn-query   CRN_PATTERN]
    [-k, --key-id      KEY_ID_OR_ALIAS]
    [-o, --output      OUTPUT]

Esempi

Questi sono esempi di kp registrations.

Gli esempi di registrazione mostrano numerosi CRN (Cloud Resource Name). I CRN seguono questo formato:

crn:version:cname:ctype:service-name:location:scope:service-instance:resource-type:resource

Vedere Nomi risorse cloud per una spiegazione dettagliata dei campi CRN.

Esempio 1

Elencare tutte le registrazioni, che possono includere risorse cloud come database, archiviazione, calcolo, contenitori o messaggistica.

Questo esempio mostra la registrazione tra Cloud Object Storage (COS) e Key Protect.

# view all registrations
$ ibmcloud kp registrations --output json

[
  {
    "keyId": "2cbea94c-6070-4a24-b0f8-7a56e4d7cb6f",
    "resourceCrn": "crn:v1:bluemix:public:cloud-object-storage:global:a/ea998d3389c3473aa0987652b46fb146:4b636e74-f3ca-40bb-80b8-3bd21801ccb8:bucket:my-cos-kms-bucket",
    "createdBy": "crn-crn:v1:bluemix:public:cloud-object-storage:global:a/ea998d3389c3473aa0987652b46fb146:4b636e74-f3ca-40bb-80b8-3bd21801ccb8::",
    "creationDate": "2020-06-15T16:07:37Z",
    "lastUpdated": "2020-06-15T16:07:37Z",
    "keyVersion": { "id": "2cbea94c-6070-4a24-b0f8-7a56e4d7cb6f", "creationDate": "2020-06-15T16:05:53Z"
    }
  }
]

Esempio 2

Questo esempio mostra l'intero ciclo di vita di due risorse cloud (Cloud Object Storage e Key Protect- dalla creazione Key Protect istanze e la creazione di una politica tra loro per eliminare le istanze.

Un riepilogo della procedura è:

Passo Dove Descrizione
1 CLI Crea istanze COS (Cloud Object Storage) e Key Protect (KP)
2 CLI Crea una politica per COS per accedere alle chiavi di codifica KP
3 CLI Crea una chiave root KP che COS utilizza per codificare i dati
4 IU console Crea un bucket COS e specifica la codifica KP; questa operazione viene eseguita nell'interfaccia utente (IU) della console perché al momento non esiste alcun supporto API o CLI
5 CLI Visualizza la registrazione KP
6 CLI Carica e scarica un oggetto per verificare che COS e KP funzionino insieme
7 CLI Elimina il bucket COS e la chiave root KP
8 CLI Elimina la politica di autorizzazione tra COS e KP
9 CLI Elimina le istanze COS e KP

Questi comandi mostrano COS e Key Protect piani di servizio. Il comando ibmcloud resource service-instance-create richiede un service plan name e un location, che si trovano nel catalogo.

# show the catalog offerings for cloud object storage (COS) and Key Protect
$ ibmcloud catalog service cloud-object-storage

$ ibmcloud catalog service kms

L'esempio copre più fasi e deve essere eseguito in consultazione con il riepilogo fornito.

# create a Cloud Object Storage (COS) instance
# "lite" is the pricing plan and "global" is the region
$ COS_NAME=my-cos-1

$ ibmcloud resource service-instance-create $COS_NAME cloud-object-storage lite global

Creating service instance my-cos-1 in resource group Default of account <account name> as <email address>...
OK
Service instance my-cos-1 was created.
Name:             my-cos-1
ID:               crn:v1:bluemix:public:cloud-object-storage:global:a/ea998d3389c3473aa0987652b46fb146:4b636e74-f3ca-40bb-80b8-3bd21801ccb8::
GUID:             4b636e74-f3ca-40bb-80b8-3bd21801ccb8
Location:         global
State:            active
Type:             service_instance
Sub Type:
Allow Cleanup:    false
Locked:           false
Created at:       2020-06-15T16:03:39Z
Updated at:       2020-06-15T16:03:39Z
Last Operation:             Status    create succeeded             Message   Completed create instance operation

# capture the COS instance id (GUID)
$ COS_INSTANCE_ID=4b636e74-f3ca-40bb-80b8-3bd21801ccb8

# create a Key Management Service (KMS) service instance
# "tiered-pricing" is the pricing plan and "us-south" is the region
$ KMS_NAME=my-kms-1

$ ibmcloud resource service-instance-create $KMS_NAME kms tiered-pricing us-south

Creating service instance my-kms-1 in resource group Default of account <account name> as <email address>...
OK
Service instance my-kms-1 was created.
Name:             my-kms-1
ID:               crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:b3933ab0-d579-46fc-8ed5-351aea657b9a::
GUID:             b3933ab0-d579-46fc-8ed5-351aea657b9a
Location:         us-south
State:            active
Type:             service_instance
Sub Type:         kms
Allow Cleanup:    false
Locked:           false
Created at:       2020-06-15T16:04:40Z
Updated at:       2020-06-15T16:04:40Z
Last Operation:             Status    create succeeded             Message   Completed create instance operation

# capture the Key Protect (KP) instance id (GUID)
$ KP_INSTANCE_ID=b3933ab0-d579-46fc-8ed5-351aea657b9a

# create a policy for COS to read KMS; source is COS, target is KMS
$ ibmcloud iam authorization-policy-create cloud-object-storage kms Reader \
  --source-service-instance-id $COS_INSTANCE_ID \
  --target-service-instance-id $KP_INSTANCE_ID

Creating authorization policy under account ea998d3389c3473aa0987652b46fb146 as <email address>...
OK
Authorization policy 18cfc980-4458-4313-972e-93f312cdcd81 was created.
ID:                        18cfc980-4458-4313-972e-93f312cdcd81
Source service name:       cloud-object-storage
Source service instance:   4b636e74-f3ca-40bb-80b8-3bd21801ccb8
Target service name:       kms
Target service instance:   b3933ab0-d579-46fc-8ed5-351aea657b9a
Roles:                     Reader

# capture the COS-to-KMS authorization policy id
$ COS_KMS_AUTHORIZATION=18cfc980-4458-4313-972e-93f312cdcd81

# create a KP root key that COS uses to encrypt data
$ ibmcloud kp key create my-cos-key --output json

{
  "id": "2cbea94c-6070-4a24-b0f8-7a56e4d7cb6f",
  "name": "my-cos-key",
  "type": "application/vnd.ibm.kms.key+json",
  "extractable": false,
  "state": 1,
  "crn": "crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:b3933ab0-d579-46fc-8ed5-351aea657b9a:key:2cbea94c-6070-4a24-b0f8-7a56e4d7cb6f"
}

# capture the KP root key id
$ MY_COS_KEY_ID=2cbea94c-6070-4a24-b0f8-7a56e4d7cb6f

# create a COS bucket and set KP encryption
#   must be done in the console user interface (UI) because
#   there is no API or CLI support at this time
# 1 - In the UI, go to... Resource list -> Storage -> my-cos-1
# 2 - Create bucket -> custom bucket
# 3 - Properties of a custom bucket
#   a - bucket name: my-cos-kms-bucket
#   b - location: us-south (same region as KP)
#   c - checkbox: Key Protect
#   d - instance: my-kms-1
#   e - key name: my-cos-key
#   f - button: Create bucket

# capture the name of the COS bucket that was created
$ COS_BUCKET=my-cos-kms-bucket

# view the KP registration; it's a result of creating the COS bucket
$ ibmcloud kp registrations --output json

[
  {
    "keyId": "2cbea94c-6070-4a24-b0f8-7a56e4d7cb6f",
    "resourceCrn": "crn:v1:bluemix:public:cloud-object-storage:global:a/ea998d3389c3473aa0987652b46fb146:4b636e74-f3ca-40bb-80b8-3bd21801ccb8:bucket:my-cos-kms-bucket",
    "createdBy": "crn-crn:v1:bluemix:public:cloud-object-storage:global:a/ea998d3389c3473aa0987652b46fb146:4b636e74-f3ca-40bb-80b8-3bd21801ccb8::",
    "creationDate": "2020-06-15T16:07:37Z",
    "lastUpdated": "2020-06-15T16:07:37Z",
    "keyVersion": { "id": "2cbea94c-6070-4a24-b0f8-7a56e4d7cb6f", "creationDate": "2020-06-15T16:05:53Z"
    }
  }
]

# list the bucket
$ ibmcloud cos list-buckets --ibm-service-instance-id $COS_INSTANCE_ID

OK
1 bucket found in your account:
Name                Date Created
my-cos-kms-bucket   Jun 15, 2020 at 16:07:38

# upload an object to COS
$ ibmcloud cos put-object --bucket $COS_BUCKET --key '/cos-file.txt' --body cos-file-upload.txt

OK
Successfully uploaded object '/cos-file.txt' to bucket 'my-cos-kms-bucket'.

# get the object from COS
$ ibmcloud cos get-object --bucket $COS_BUCKET --key '/cos-file.txt' cos-file-download.txt

OK
Successfully downloaded '/cos-file.txt' from bucket 'my-cos-kms-bucket'
20 B downloaded.

# verify that the upload and download files are the same
$ cat cos-file-upload.txt

This is a test file

$ cat cos-file-download.txt

This is a test file

# delete the object
$ ibmcloud cos delete-object --bucket $COS_BUCKET --key '/cos-file.txt' --force

OK
Delete '/cos-file.txt' from bucket 'my-cos-kms-bucket' ran successfully.

# delete the bucket
$ ibmcloud cos delete-bucket --bucket $COS_BUCKET --force

OK
Successfully deleted bucket 'my-cos-kms-bucket'. The bucket 'my-cos-kms-bucket' will be available for reuse after 15 minutes.

# list the bucket (it should no longer exist)
$ ibmcloud cos list-buckets --ibm-service-instance-id $COS_INSTANCE_ID

OK
No buckets found in your account.

# view the KP registration (it should no longer exist)
$ ibmcloud kp registrations --output json

# delete the KP root key; COS no longer uses it
$ ibmcloud kp key delete $MY_COS_KEY_ID --output json

{
  "id": "2cbea94c-6070-4a24-b0f8-7a56e4d7cb6f"
}

# delete the authorization policy between COS AND KMS
$ ibmcloud iam authorization-policy-delete $COS_KMS_AUTHORIZATION --force

Deleting authorization policy 18cfc980-4458-4313-972e-93f312cdcd81 under account ea998d3389c3473aa0987652b46fb146...
OK
Authorization policy 18cfc980-4458-4313-972e-93f312cdcd81 is deleted successfully

# view the authorization policy (it should no longer exist)
$ ibmcloud iam authorization-policies

Getting authorization policies under account ea998d3389c3473aa0987652b46fb146 as <email address>...
OK
No policy found

# delete the KMS instance
$ ibmcloud resource service-instance-delete $KMS_NAME --force

Deleting service instance my-kms-1 in resource group Default under account <account name> as <email address>...
OK
Service instance my-kms-1 with ID crn:v1:bluemix:public:kms:us-south:a/ea998d3389c3473aa0987652b46fb146:b3933ab0-d579-46fc-8ed5-351aea657b9a:: is deleted successfully

# delete the COS instance
$ ibmcloud resource service-instance-delete $COS_NAME --force

Deleting service instance my-cos-1 in resource group Default under account <account name> as <email address>...
OK
Service instance my-cos-1 with ID crn:v1:bluemix:public:cloud-object-storage:global:a/ea998d3389c3473aa0987652b46fb146:4b636e74-f3ca-40bb-80b8-3bd21801ccb8:: is deleted successfully

# view resources (COS and KMS should no longer exist)
$ ibmcloud resource service-instances

Retrieving instances with type service_instance in resource group Default in all locations under account <account name> as <email address>...
OK
No service instance found.

Esempio 3

Questo esempio mostra cosa accade quando si verifica una delle seguenti situazioni tra COS e Key Protect (KP)- COS non è in grado di accedere alla chiave root Key Protect.

  • Elimina chiave root KP
  • Rimuovere la politica di autorizzazione CMS/KP

Questo esempio non mostra l'output del comando tranne quando pertinente.

# create a Cloud Object Storage (COS) service instance
# "lite" is the pricing plan and "global" is the region
$ COS_NAME=my-cos-1

$ ibmcloud resource service-instance-create $COS_NAME cloud-object-storage lite global

# capture the COS instance id (GUID)
$ COS_INSTANCE_ID=c488e11a-c8a0-4688-b002-9327266ea55f

# create a Key Management Service (KMS) service instance
# "tiered-pricing" is the pricing plan and "us-south" is the region
$ KMS_NAME=my-kms-1

$ ibmcloud resource service-instance-create $KMS_NAME kms tiered-pricing us-south

# capture the Key Protect (KP) instance id (GUID)
$ KP_INSTANCE_ID=26f4b198-952a-47ab-9f44-ef69c038b3c5

# create a policy for COS to read KMS; source is COS, target is KMS (Key Protect)
$ ibmcloud iam authorization-policy-create cloud-object-storage kms Reader \
  --source-service-instance-id $COS_INSTANCE_ID \
  --target-service-instance-id $KP_INSTANCE_ID

# capture the COS-to-KMS authorization policy id
$ COS_KMS_AUTHORIZATION=594b946e-0e90-44ea-ac62-6cbb42450cd5

# create a KP root key that COS uses to encrypt data
$ ibmcloud kp key create my-cos-key --output json

# capture the KP root key id
$ MY_COS_KEY_ID=464d78c3-57dc-49a5-b932-8ebf8f8c7771

# create a COS bucket and set KP encryption
#   must be done in the console user interface (UI) because
#   there is no API or CLI support at this time

# capture the name of the COS bucket that was created
$ COS_BUCKET=my-cos-kms-bucket

# upload an object to COS
$ ibmcloud cos put-object --bucket $COS_BUCKET --key '/cos-file.txt' --body cos-file-upload.txt

# delete the authorization policy between COS AND KMS - this breaks everything
$ ibmcloud iam authorization-policy-delete $COS_KMS_AUTHORIZATION --force

# get the object from COS - this fails because COS no longer has access to KMS
$ ibmcloud cos get-object --bucket $COS_BUCKET --key '/cos-file.txt' cos-file-download.txt

FAILED
ServiceNotAuthorized: The specified COS Service Instance does not have sufficient
    permissions to access the resource provided in the ibm-sse-kp-customer-root-key-crn request header
status code: 401,
request id: a51e1da3-9bf7-4cc9-9eb0-0d074c7f9093,
host id:

# delete the object
$ ibmcloud cos delete-object --bucket $COS_BUCKET --key '/cos-file.txt' --force

# delete the bucket
$ ibmcloud cos delete-bucket --bucket $COS_BUCKET --force

# delete the KP root key - this fails because the registration was not deleted
$ ibmcloud kp key delete $MY_COS_KEY_ID --output json

FAILED
kp.Error:
    correlation_id='fffdd8a9-405a-4a91-a5a7-52c30d11424d',
    msg='Conflict: Key could not be deleted. Please see "reasons" for more details.',
    reasons='[PROTECTED_RESOURCE_ERR: Key is protecting one or more cloud resources -
        FOR_MORE_INFO_REFER: https://cloud.ibm.com/docs/key-protect?topic=key-protect-troubleshooting#unable-to-delete-keys]'

# delete the KP root key; use --force because the registration between COS and KMS still exists
$ ibmcloud kp key delete $MY_COS_KEY_ID --force --output json

# delete the KMS instance
$ ibmcloud resource service-instance-delete $KMS_NAME --force

# delete the COS instance
$ ibmcloud resource service-instance-delete $COS_NAME --force

# view resources (COS and KMS should no longer exist)
$ ibmcloud resource service-instances

Retrieving instances with type service_instance in resource group Default in all locations under account <account name> as <email address>...
OK
No service instance found.

Parametri obbligatori

  • KEY_ID_OR_ALIAS

    L'UUID o alias v4 della chiave che vuoi interrogare.

  • -i, --instance-id

    L'ID dell'istanza di IBM Cloud che identifica la tua istanza di Key Protect.

    Puoi impostare una variabile di ambiente invece di specificare -i con il seguente comando: $ export KP_INSTANCE_ID=<INSTANCE_ID>.

Parametri facoltativi

  • -c, --crn-query

    Specificare la query crn le cui registrazioni devono essere elencate

  • -k, --key-id

    Specificare l'ID chiave le cui registrazioni devono essere elencate.

  • -o, --output

    Imposta il formato di output della CLI. Per impostazione predefinita, tutti i comandi vengono restituiti nel formato tabella. Per modificare il formato di output in JSON, utilizzare --output json.

    L'impostazione dell'output su JSON (--output json) include il CRN (cloud resource name) nell'output.

  • -r, --key-ring

    Un nome univoco e leggibile dall'utente per il portachiavi. Richiesto per mostrare le registrazioni sul keyring fornito.

comando ibmcloud kp kmip

I comandi KMIP consentono l'accesso API agli oggetti e agli adattatori KMIP.

Sottocomando Stato v0.10 Descrizione
creazione adattatore Crea un adattatore KMIP
adapter Richiama un adattatore KMIP
Adattatori Elencare gli adattatori KMIP in un'istanza
eliminazione adattatore Elimina un adattatore KMIP
creazione certificato Crea un certificato client KMIP associato a un adattatore
CERT Richiama un certificato client KMIP
certificati Elencare il Certificato client KMIP associato a un adattatore KMIP
eliminazione certificato Elimina un certificato client KMIP
oggetto Richiama un oggetto KMIP
oggetti Elencare gli oggetti KMIP in un adattatore KMIP
oggetto - elimina Elimina un oggetto KMIP

adattatore kmip kp - create

Utilizzare kmip adapter-create per creare un adattatore KMIP in un'istanza Key Protect. Gli adattatori vengono utilizzati per raggruppare e gestire gli oggetti KMIP. Gli adattatori KMIP nella stessa istanza Key Protect devono avere un nome univoco, poiché gli adattatori possono essere richiamati dal nome o dall'ID. Per tutti i comandi CLI relativi a KMIP, qualsiasi argomento o indicatore che utilizza un ID adattatore può utilizzare anche un nome adattatore.

A seconda del profilo, potrebbe essere necessario fornire informazioni diverse per creare l'adattatore. Attualmente, è supportato un solo profilo di adattatore KMIP: native_1.0.

Il profilo native_1.0 richiede solo l'ID di una chiave root da fornire nell'indicatore -k.

$ ibmcloud kp kmip adapter-create
    -i, --instance-id      INSTANCE_ID
    -p, --profile PROFILE
    [-k, --crk-id CRK_ID]
    [-n, --name NAME]
    [-d, --description DESC]
    [-o, --output          OUTPUT]

Esempio

Questi sono esempi di kp kmip adapter-create.

Esempio 1

Questo esempio crea l'adattatore KMIP con il profilo di native_1.0

$ ibmcloud kp kmip adapter-create -n myadapter -k 47a0ad90-204d-4e45-aa5b-68ed40a05fa2 -p native_1.0 -d "my description"
Targeting endpoint: not shown
Creating KMIP Adapter...
OK
Adapter ID                             Adapter Profile   Adapter Name   Adapter Description   
d6a00af1-277f-40e8-b33e-da3a68752209   native_1.0        myadapter      my description  
$ ibmcloud kp kmip adapters
Targeting endpoint: not shown
Listing KMIP Adapters...
OK
Adapter ID                             Adapter Profile   Adapter Name   Created At                      Updated At   
d6a00af1-277f-40e8-b33e-da3a68752209   native_1.0        myadapter      2024-03-20 22:06:43 +0000 UTC   2024-03-20 22:06:43 +0000 UTC   

adattatore kp kmip

Richiamare i dettagli su un adattatore KMIP, inclusa la data di creazione e di aggiornamento. È possibile utilizzare l'ID adattatore o il nome adattatore.

$ ibmcloud kp kmip adapter ADAPTER_NAME_OR_ID
    -i, --instance-id   INSTANCE_ID
    [-o, --output       OUTPUT]

Esempio

Questi sono esempi di kp kmip adapter.

Esempio 1

Tenere presente che esistono alcuni attributi per l'adattatore visibili solo nel formato di output JSON.

$ ibmcloud kp key create rootKmip
Targeting endpoint: not shown
Creating key: 'rootKmip', in instance: '8944cc2d-7e00-46b2-baa4-787051e0f7b3'...
OK
Key ID                                 Key Name   
47a0ad90-204d-4e45-aa5b-68ed40a05fa2   rootKmip   
$ ibmcloud kp kmip adapter-create -n myadapter -k 47a0ad90-204d-4e45-aa5b-68ed40a05fa2 -p native_1.0
Targeting endpoint: not shown
Creating KMIP Adapter...
OK
Adapter ID                             Adapter Profile   Adapter Name   Adapter Description   
d6a00af1-277f-40e8-b33e-da3a68752209   native_1.0        myadapter      -   
# retreiving adapter by name
$ ibmcloud kp kmip adapter myadapter
Targeting endpoint: not shown
Getting KMIP Adapter...
OK
Adapter ID                             Adapter Profile   Adapter Name   Created At                      Updated At                      Adapter Description   
d6a00af1-277f-40e8-b33e-da3a68752209   native_1.0        myadapter      2024-03-20 22:06:43 +0000 UTC   2024-03-20 22:06:43 +0000 UTC   -   
# retrieving adapter by ID
$ ibmcloud kp kmip adapter d6a00af1-277f-40e8-b33e-da3a68752209 -o json
{
    "id": "d6a00af1-277f-40e8-b33e-da3a68752209",
    "profile": "native_1.0",
    "profile_data": {
        "crk_id": "47a0ad90-204d-4e45-aa5b-68ed40a05fa2"
    },
    "name": "myadapter",
    "description": "",
    "created_by": "IBMid-664003LB2T",
    "created_at": "2024-03-20T22:06:43Z",
    "updated_by": "IBMid-664003LB2T",
    "updated_at": "2024-03-20T22:06:43Z"
}

adattatori kp kmip

Elenca gli adattatori KMIP disponibili nella tua istanza Key Protect.

$ ibmcloud kp kmip adapters
    -i, --instance-id       INSTANCE_ID
    [-o, --output           OUTPUT]
    [-n, --limit            LIMIT]
    [-s, --starting-offset  OFFSET]
    [-t, --total-count]
    [-k, --crk-id           CRK_ID]

Esempio

Questi sono esempi di kp kmip adapters. Usa il -k flag per mostrare solo gli adattatori che utilizzano un ID CRK specifico.

Esempio 1

$ ibmcloud kp kmip adapters -n 100 -s 0
Targeting endpoint: not shown
Listing KMIP Adapters...
OK
Adapter ID                             Adapter Profile   Adapter Name   Created At                      Updated At   
d6a00af1-277f-40e8-b33e-da3a68752209   native_1.0        myadapter      2024-03-20 22:06:43 +0000 UTC   2024-03-20 22:06:43 +0000 UTC

adattatore kmip kp - elimina

Elimina un adattatore KMIP. In questo modo verranno eliminati tutti gli oggetti e i certificati associati all'adattatore.

$ ibmcloud kp kmip adapter-delete ADAPTER_NAME_OR_ID
    -i, --instance-id INSTANCE_ID
    [-f, --force]
    [-y, --skip-confirm]

Esempio

Questi sono esempi di kp kmip adapter-delete.

Esempio 1

$ ibmcloud kp kmip adapter-create -n adap -k 47a0ad90-204d-4e45-aa5b-68ed40a05fa2 -p native_1.0
Targeting endpoint: not shown
Creating KMIP Adapter...
OK
Adapter ID                             Adapter Profile   Adapter Name   Adapter Description   
e97e4297-4a6f-41c9-ae67-0920715964fd   native_1.0        adap           -   
$ ibmcloud kp kmip adapter-delete e97e4297-4a6f-41c9-ae67-0920715964fd
Targeting endpoint: not shown
Deleting KMIP Adapter...
OK

kp kmip cert - create

Utilizzare kp kmip cert-create per creare un certificato client KMIP da associare a uno specifico adattatore KMIP. Il certificato fornito nel flag -c deve essere nel formato x509 PEM. Il file del certificato può essere caricato utilizzando il prefisso @ per specificare un percorso file o fornendo il contenuto del file del certificato direttamente all'indicatore.

I certificati client KMIP sono utilizzati per connettersi e autenticarsi al server KMIP attraverso il sito TLS ( mTLS ). Un certificato deve essere registrato prima che le operazioni del protocollo KMIP possano essere eseguite con un adattatore KMIP. L'utilizzo del certificato nelle operazioni KMIP può richiedere fino a 5 minuti.

I certificati devono avere un nome univoco all'interno dello stesso adattatore KMIP e il contenuto del certificato deve essere univoco, anche tra più adattatori.

Vedere anche: Specifiche protocollo KMIP

$ ibmcloud kp kmip cert-create
    -a, --adapter       ADAPTER_NAME_OR_ID
    -c, --cert-string   {@path/to/cert | CERTIFICATE_STRING}
    [-n, --name         NAME]
    -i, --instance-id   INSTANCE_ID
    [-o, --output       OUTPUT]

Esempio

Questi sono esempi di kp kmip cert-create.

Esempio 1

Questo esempio mostra due modi per caricare lo stesso file di certificato.

$ ibmcloud kp key create rootKmip
Targeting endpoint: not shown
Creating key: 'rootKmip', in instance: '8944cc2d-7e00-46b2-baa4-787051e0f7b3'...
OK
Key ID                                 Key Name   
47a0ad90-204d-4e45-aa5b-68ed40a05fa2   rootKmip   
$ ibmcloud kp kmip adapter-create -n myadapter -k 47a0ad90-204d-4e45-aa5b-68ed40a05fa2 -p native_1.0
Targeting endpoint: not shown
Creating KMIP Adapter...
OK
Adapter ID                             Adapter Profile   Adapter Name   Adapter Description   
d6a00af1-277f-40e8-b33e-da3a68752209   native_1.0        myadapter      -   

$ export CERT=$(cat ./cert.pem)

$ ibmcloud kp kmip cert-create -n mycert -c "$CERT" -a myadapter
Targeting endpoint: not shown
Creating KMIP Client Certificate...
OK
Certificate ID                         Certificate Name   Created At   
3f550b96-86bc-44fe-8d1d-113e57067219   mycert             2024-03-20 22:08:03 +0000 UTC   

## Alternatively, you can also provide the filepath of the certificate

$ ibmcloud kp kmip cert-delete mycert -a myadapter
Targeting endpoint: not shown
Deleting KMIP Client Certificate...
OK

$ ibmcloud kp kmip cert-create -n mycert -c @./cert.pem -a myadapter
Targeting endpoint: not shown
Creating KMIP Client Certificate...
OK
Certificate ID                         Certificate Name   Created At   
a279fded-06d1-45a1-8a95-901f194fb937   mycert             2024-03-20 22:11:34 +0000 UTC   

certificato kmip kp

Richiama un certificato client KMIP specifico. Un certificato può essere richiamato dall'ID o dal nome.

$ ibmcloud kp kmip cert CERTIFICATE_ID
    -a, --adapter       ADAPTER_NAME_OR_ID
    -i, --instance-id   INSTANCE_ID
    [-o, --output       OUTPUT]

Esempi

Questi sono esempi di kp kmip cert.

Esempio 1

Acquisizione di un certificato in base al nome:

$ ibmcloud kp kmip cert mycert -a myadapter
Targeting endpoint: not shown
Getting KMIP Client Certificate...
OK
Certificate ID                         Certificate Name   Created At   
a279fded-06d1-45a1-8a95-901f194fb937   mycert             2024-03-20 22:11:34 +0000 UTC   

Esempio 2

Ottenimento di un certificato in base all'UUID in formato JSON. Il contenuto del certificato in formato PEM sarà restituito nel corpo JSON.

$ ibmcloud kp kmip cert a279fded-06d1-45a1-8a95-901f194fb937  -a myadapter -o json
{
    "id": "a279fded-06d1-45a1-8a95-901f194fb937",
    "name": "mycert",
    "certificate": "-----BEGIN CERTIFICATE-----\nMIIFqzCCA5OgAwIBAgIUNXqfJMkAHOBHz6+ekETDlCqIEqUwDQYJKoZIhvcNAQEL\nBQAw
    ... CERTIFICATE CONTENTS ABBREVIATED ...
    Y6uFtHuQSpud0C\n-----END CERTIFICATE-----\n",
    "created_by": "IBMid-12345678",
    "created_at": "2024-03-20T22:11:34Z"
}

certificati kp kmip

Elencare tutti i certificati client KMIP associati a un adattatore KMIP specifico.

$ ibmcloud kp kmip certs
    -a, --adapter           ADAPTER_NAME_OR_ID
    [-n, --limit            LIMIT]
    [-s, --starting-offset  OFFSET]
    [-t, --total-count]
    -i, --instance-id       INSTANCE_ID
    [-o, --output           OUTPUT]

Esempi

Questi sono esempi di kp kmip certs.

Esempio 1

$ ibmcloud kp kmip certs -a myadapter
Targeting endpoint: not shown
Listing KMIP Client Certificates...
OK
Certificate ID                         Certificate Name   Created At   
a279fded-06d1-45a1-8a95-901f194fb937   mycert             2024-03-20 22:11:34 +0000 UTC   

kp kmip cert - delete

Eliminare un certificato client KMIP.

$ ibmcloud kp kmip cert-delete CERTIFICATE_ID
    -a, --adapter         ADAPTER_NAME_OR_ID
    -i, --instance-id     INSTANCE_ID

Esempi

Questi sono esempi di kp kmip cert-delete

Esempio 1

$ ibmcloud kp kmip cert-delete -a myadapter mycert
Targeting endpoint: not shown
Deleting KMIP Client Certificate...
OK

oggetto kmip kp

Gli oggetti KMIP vengono creati tramite operazioni eseguite tramite un client KMIP utilizzando il protocollo KMIP. Non possono essere creati tramite l'API, ma possono essere letti ed eliminati. Gli oggetti appartengono ad un singolo adattatore.

Gli oggetti non hanno un nome e devono essere richiamati dall'ID.

$ ibmcloud kp kmip object OBJECT_ID
    -a, --adapter         ADAPTER_NAME_OR_ID
    -i, --instance-id     INSTANCE_ID
    [-o, --output         OUTPUT]

Esempi

Questi sono esempi di kp kmip object

Esempio 1

$ ibmcloud kp kmip object 12365a82-5404-4bd9-a4c7-2b628ee18304 -a testadapter
Targeting endpoint: not shown
Getting KMIP Object...
OK
Object ID                              Object Type     Object State   Created At                      Updated At   
12365a82-5404-4bd9-a4c7-2b628ee18304   Symmetric Key   Active         2024-03-14 21:01:45 +0000 UTC   2024-03-14 21:01:45 +0000 UTC   

Esempio 2

Il richiamo di un oggetto KMIP come JSON mostrerà alcuni ulteriori attributi non visibili nella normale vista tabella.

$ ibmcloud kp kmip object 12365a82-5404-4bd9-a4c7-2b628ee18304 -a testadapter -o json
{
    "id": "12365a82-5404-4bd9-a4c7-2b628ee18304",
    "kmip_object_type": 2,
    "state": 2,
    "created_by_kmip_client_cert_id": "531c18f3-4e37-447e-a7e0-e8676407bb75",
    "created_by": "IBMid-123456",
    "created_at": "2024-03-14T21:01:45Z",
    "updated_by_kmip_client_cert_id": "531c18f3-4e37-447e-a7e0-e8676407bb75",
    "updated_by": "IBMid-123456",
    "updated_at": "2024-03-14T21:01:45Z"
}

oggetti kp kmip

Elencare gli oggetti KMIP e visualizzare le informazioni relative al tipo di oggetto e allo stato dell'oggetto tra gli altri metadati. Utilizzare il flag -f per filtrare gli oggetti solo in stato specifico. Per default, il filtro di stato è impostato su 1,2,3,4.

I numeri corrispondono agli stati dell'oggetto come segue:

  • Pre - attivo = 1
  • Attivo = 2
  • Disattivato = 3
  • Compromesso = 4
  • Eliminato = 5
  • Compromesso distrutto = 6

Vedere KMIP State Enumeration

ibmcloud kp kmip objects
    -a, --adapter           ADAPTER_NAME_OR_ID
    [-n, --limit            LIMIT]
    [-s, --starting-offset  OFFSET]
    [-t, --total-count]
    -i, --instance-id       INSTANCE_ID
    [-o, --output           OUTPUT]

Esempi

Questi sono esempi di kp kmip objects.

Esempio 1

$ ibmcloud kp kmip objects -a myadapter
Targeting endpoint: not shown
Listing KMIP Objects...
OK
Object ID                              Object Type     Object State   Created At                      Updated At   
00196c59-c5c2-42d8-9729-703cd0389f60   Symmetric Key   Compromised    2024-03-14 20:47:54 +0000 UTC   2024-03-14 20:47:54 +0000 UTC   
02f1043c-0494-4399-82af-5395a14b019f   Symmetric Key   Pre-Active     2024-03-14 20:58:06 +0000 UTC   2024-03-14 20:58:06 +0000 UTC   
08082ff4-821b-4689-83ec-15cac5bd1939   Symmetric Key   Pre-Active     2024-02-22 00:10:46 +0000 UTC   2024-02-22 00:11:23 +0000 UTC   
0c1ea28d-dfaa-404a-b9c4-fcdc3f5d8b02   Symmetric Key   Deactivated    2024-03-14 21:05:48 +0000 UTC   2024-03-14 21:05:48 +0000 UTC   
10b49b05-0101-4234-927b-20a3356da291   Symmetric Key   Pre-Active     2024-03-14 21:26:54 +0000 UTC   2024-03-14 21:26:54 +0000 UTC   
12365a82-5404-4bd9-a4c7-2b628ee18304   Symmetric Key   Active         2024-03-14 21:01:45 +0000 UTC   2024-03-14 21:01:45 +0000 UTC

Esempio 2

Utilizzo dell'indicatore -f per filtrare gli oggetti di un determinato stato. Utilizzare le virgole per specificare più stati.

$ ibmcloud kp kmip objects -a testadapter -f 5,6
Targeting endpoint: not shown
Listing KMIP Objects...
OK
Object ID                              Object Type     Object State            Created At                      Updated At   
03d38805-2bb2-4aa0-bbf3-dc4a6d5d0475   Symmetric Key   Destroyed               2024-03-14 20:47:58 +0000 UTC   2024-03-14 20:47:58 +0000 UTC   
08c94f34-0100-4331-b759-5937ed5b1228   Symmetric Key   Destroyed               2024-03-14 20:46:38 +0000 UTC   2024-03-14 20:46:38 +0000 UTC   
1a13e112-41f8-4d52-be08-a0946b8c22fa   Symmetric Key   Destroyed Compromised   2024-03-14 20:58:20 +0000 UTC   2024-03-14 20:58:20 +0000 UTC   

Oggetto kmip kp - delete

Eliminare un oggetto KMIP. Solo gli oggetti il cui stato non è Attivo o Non eliminato possono essere eliminati correttamente.

$ ibmcloud kp kmip object-delete OBJECT_ID
    -a, --adapter ADAPTER_NAME_OR_ID
    -i, --instance-id INSTANCE_ID
    [-f, --force]
    [-y, --skip-confirm]

Esempi

Questi sono esempi di kp kmip object-delete

Esempio 1

$ ibmcloud kp kmip object-delete 9b2f5af5-3534-4f02-8836-f89af37c4351 -a testadapter
Targeting endpoint: not shown
Deleting KMIP Object...
OK

unità crittografica kp

Il comando kp crypto-unit consente di gestire le unità crittografiche. Si noti che questo comando non fa nulla da solo. È necessario utilizzare uno dei sottocomandi insieme ad esso.

NAME:
  -ibmcloud key-protect crypto-unit - Manage crypto units

USAGE:
  ibmcloud key-protect crypto-unit command [arguments...] [command options]

COMMANDS:
  claim        Claim crypto unit(s)
  master-key   Commands to manage Master Keys (MKs) of crypto unit(s)
  master-keys  List the MKs uploaded to crypto unit(s)
  sig-key      Generate a signature key file compatible for use as a crypto unit user credential
  user         Manage users in crypto unit(s)
  users        List users in crypto unit(s)
  zeroize      Zeroize a crypto unit
  help, h      Show help

Enter 'ibmcloud key-protect crypto-unit help [command]' for more information about a command.

Se si verificano problemi con il comando kp crypto-unit, vedere la sezione Risoluzione dei problemi.

zeroize

L'azzeramento delle unità crittografiche è altamente sconsigliato una volta create le chiavi o eseguite le operazioni sulle chiavi. Se l'azzeramento è necessario dopo questo punto, tutte le chiavi devono essere cancellate ed eliminate. È necessario un periodo di attesa di quattro ore prima che una chiave cancellata possa essere eliminata.

NAME:
  zeroize - Zeroize a crypto unit

USAGE:
  zeroize --id CRYPTO_UNIT_ID

OPTIONS:
  --id value                     Required. The ID of the crypto unit to zeroize

claim

rivendicazione di unità crittografiche ibmcloud kp

NAME:
  claim - Claim crypto unit(s)

USAGE:
  claim --credential ADMIN_KEY_FILE

OPTIONS:
  --credential value  Required. Path to file containing signature key that will be associated with the user. Must be between 1 and 255 characters. Do not include file passphrase
  --ids strings         Optional. List of crypto unit IDs to target, can be provided as a comma-separated list, or repeating the flag. If omitted, all crypto units will be targeted

master-key

NAME:
  ibmcloud key-protect crypto-unit master-key - Commands to manage Master Keys (MKs) of crypto unit(s)

USAGE:
  ibmcloud key-protect crypto-unit master-key command [arguments...] [command options]

COMMANDS:
  generate   Generate Master Key (MK) material. This command does not store the MK material in crypto unit used to generate it. Use `crypto-unit master-key import` to upload an MK to a crypto unit
  import     Import a Master Key (MK) to crypto unit(s)
  help, h    Show help

master-key generate

NAME:
  generate - Generate Master Key (MK) material. This command does not store the MK material in crypto unit used to generate it. Use `crypto-unit master-key import` to upload an MK to a crypto unit

USAGE:
  generate --keyshare-files KEYSHARE_FILES --keyshare-minimum KEYSHARE_MINIMUM --algo ALGO --key-name KEYNAME --cu CRYPTO_UNITS

OPTIONS:
  --algo value              Required. Algorithm that generated MK will be compatible with. Only AES-256 is supported
  --auth value              Credentials to use for authenticating request(s) sent to crypto unit(s). Format: '[{"myUsername": "/path/to/signature.key#filepassphrase"}]' or '@/path/to/auth.json'. Omit # to be prompted to enter file passphrase. --auth and --cu are mutually exclusive
  --cu value                Crypto unit(s) for the request to target and credentials to submit request with. Format: '[{"CryptoUnitId": "fadedbee-0000-0000-0000-1234567890ab", "Auth": [{"ADMIN": "/path/to/signature.key#filepassphrase"}]}]' or '@/path/to/cu.json'. Omit # to be prompted to enter file passphrase. --auth and --cu are mutually exclusive
  --key-name value          Required. MK name. Must be between 1 and 8 characters
  --keyshare-files value    Required. Array specifying file paths to write MK key share files to. Format: '["file1.key#filepwd1", "file2.key#filepwd2"]'. File path must be 1-255 characters. Passphrase must be between 6 and 255 characters. Omit # to be prompted to enter file passphrase.
  --keyshare-minimum value  Required. Number of key shares needed to reconstruct the MK. Must be between 2 and 255 and less than or equal to the number of keyshare files

master-key import

NAME:
  import - Import a Master Key (MK) to crypto unit(s)

USAGE:
  import --keyshare-files KEYSHARE_FILES --auth AUTH

OPTIONS:
  --auth value            Credentials to use for authenticating request(s) sent to crypto unit(s). Format: '[{"myUsername": "/path/to/signature.key#filepassphrase"}]' or '@/path/to/auth.json'. Omit # to be prompted to enter file passphrase. --auth and --cu are mutually exclusive
  --cu value              Crypto unit(s) for the request to target and credentials to submit request with. Format: '[{"CryptoUnitId": "fadedbee-0000-0000-0000-1234567890ab", "Auth": [{"ADMIN": "/path/to/signature.key#filepassphrase"}]}]' or '@/path/to/cu.json'. Omit # to be prompted to enter file passphrase. --auth and --cu are mutually exclusive
  --keyshare-files value  Required. Array specifying file paths to MK key share files. Format: '["file1.key#filepwd1", "file2.key#filepwd2"]'. File path must be 1-255 characters. Passphrase must be between 6 and 255 characters. Omit # to be prompted to enter file passphrase.

master-keys

NAME:
  master-keys - List the MKs uploaded to crypto unit(s)

USAGE:
  master-keys [--cu CRYPTO_UNITS]

OPTIONS:
  --cu value  Optional. Crypto unit(s) for the request to target and credentials to submit request with. Format: '[{"CryptoUnitId": "fadedbee-0000-0000-0000-1234567890ab", "Auth": [{"ADMIN": "/path/to/signature.key#filepassphrase"}]}]' or '@/path/to/cu.json'. Omit # to be prompted to enter file passphrase. --auth and --cu are mutually exclusive. If omitted, lists MKs in all crypto units of the instance.

sig-key

NAME:
  ibmcloud key-protect crypto-unit sig-key - Generate a signature key file compatible for use as a crypto unit user credential

USAGE:
  ibmcloud key-protect crypto-unit sig-key command [arguments...] [command options]

COMMANDS:
  generate   Generate a signature key file compatible for use as a crypto unit user credential
  help, h    Show help

Enter 'ibmcloud key-protect crypto-unit sig-key help [command]' for more information about a command.

sig-key generate

NAME:
  generate - Generate a signature key file compatible for use as a crypto unit user credential

USAGE:
  generate --file FILE --passphrase PASSWORD --algo RSA-2048

OPTIONS:
  --algo value      The algorithm type used to generate the signature key. Only RSA-2048 is supported
  --file value      Required. The file path to write the signature key to. Must be between 1 and 255 characters
  --passphrase value                 --passphrase string   Optional passphrase used to encrypt the signature key file. Provide "-" to prompt for password

user

NAME:
  ibmcloud key-protect crypto-unit user - Manage users in crypto unit(s)

USAGE:
  ibmcloud key-protect crypto-unit user command [arguments...] [command options]

COMMANDS:
  add       Add new user to crypto unit(s)
  remove    Remove user from crypto unit
  help, h   Show help

Enter 'ibmcloud key-protect crypto-unit user help [command]' for more information about a command.

user-add

NAME:
  add - Add new user to crypto unit(s)

USAGE:
  add --type TYPE --name NAME --credential CREDENTIAL --auth AUTH

OPTIONS:
  --auth value          Credentials to use for authenticating request(s) sent to crypto unit(s). Format: '[{"myUsername": "/path/to/signature.key#filepassphrase"}]' or '@/path/to/auth.json'. Omit # to be prompted to enter file passphrase. --auth and --cu are mutually exclusive
  --credential value    Required. Path to file containing signature key that will be associated with the user. Must be between 1 and 255 characters. Do not include file passphrase
  --cu value            Crypto unit(s) for the request to target and credentials to submit request with. Format: '[{"CryptoUnitId": "fadedbee-0000-0000-0000-1234567890ab", "Auth": [{"ADMIN": "/path/to/signature.key#filepassphrase"}]}]' or '@/path/to/cu.json'. Omit # to be prompted to enter file passphrase. --auth and --cu are mutually exclusive
  --name value        Required. Name of the user to add. Must be between 1 and 255 characters
  --type value        Required. Type of user to add. Allowable values are: admin, kmsCryptoUser

user-remove

NAME:
  remove - Remove user from crypto unit

USAGE:
  remove -u USER --cu CRYPTO_UNITS

OPTIONS:
  --cu value              Crypto unit(s) for the request to target and credentials to submit request with. Format: '[{"CryptoUnitId": "fadedbee-0000-0000-0000-1234567890ab", "Auth": [{"ADMIN": "/path/to/signature.key#filepassphrase"}]}]' or '@/path/to/cu.json'. Omit # to be prompted to enter file passphrase. --auth and --cu are mutually exclusive
  -u value, --user value  Required. The username of the user to remove from crypto-unit(s)

users

NAME:
  users - List users in crypto unit(s)

USAGE:
  users [--cu CRYPTO_UNITS]

OPTIONS:
  --cu value  Optional. Crypto unit(s) for the request to target. Format: '[{"CryptoUnitId": "fadedbee-0000-0000-0000-1234567890ab"}]' or '@/path/to/cu.json'. If omitted, lists users in all crypto units of the instance.

kp crypto-units

Il comando kp crypto-units consente di elencare le unità crittografiche.


NAME:
  ibmcloud kp - List crypto units allocated to instance

USAGE:
  ibmcloud crypto-units

COMMANDS:

Additional help topics:

Use "export KP_INSTANCE_ID=TARGET_INSTANCE_ID" or "ibmcloud kp command [arguments...] [command options] -i TARGET_INSTANCE_ID" to set a target instance ID.

Passi successivi

Cerca le operazioni correlate nella documentazione dell'API.