En esta página, se muestra cómo rotar una clave de forma automática o manual. Para obtener más información sobre la rotación de claves en general, consulta Rotación de claves.
Roles obligatorios
Si deseas obtener los permisos que necesitas para rotar las claves, haz lo siguiente: solicita a tu administrador que te otorgue el los siguientes roles de IAM en tu clave:
-
Administrador de Cloud KMS (
roles/cloudkms.admin
) -
Vuelve a encriptar los datos:
Encriptador/Desencriptador de CryptoKey de Cloud KMS (
roles/cloudkms.cryptoKeyEncrypterDecrypter
)
Para obtener más información sobre cómo otorgar roles, consulta Administra el acceso a proyectos, carpetas y organizaciones.
Estos roles predefinidos contienen los permisos necesarios para rotar las claves. Para ver los permisos exactos que son necesarios, expande la sección Permisos requeridos:
Permisos necesarios
Se requieren los siguientes permisos para rotar claves:
-
Cambia la versión de clave primaria:
cloudkms.cryptoKeys.update
-
Cambia o inhabilita la rotación automática:
cloudkms.cryptoKeys.update
-
Crea una versión de clave nueva:
cloudkms.cryptoKeyVersions.create
-
Inhabilita las versiones de clave anteriores:
cloudkms.cryptoKeyVersions.update
-
Vuelve a encriptar los datos:
-
cloudkms.cryptoKeyVersions.useToDecrypt
-
cloudkms.cryptoKeyVersions.useToEncrypt
-
También puedes obtener estos permisos con roles personalizados o con otros roles predefinidos.
Un solo usuario con un rol personalizado que contenga todos estos permisos puede rotar las claves y volver a encriptar los datos por su cuenta. Usuarios en el rol de administrador de Cloud KMS y los roles de Encriptador/Desencriptador de CryptoKey de Cloud KMS pueden funcionar en conjunto para rotar claves y volver a encriptar los datos. Sigue el principio de privilegio mínimo cuando asignes roles de seguridad. Para obtener más detalles, consulta Roles y permisos.
Cuando rotas una clave, los datos que se encriptaron con versiones de claves anteriores no se vuelven a encriptar de forma automática. Para obtener más información, consulta desencriptar y volver a encriptar. La rotación de una clave no inhabilita ni destruye de forma automática ninguna versión de clave existente.
Configura la rotación automática
Para configurar la rotación automática cuando creas una clave nueva, haz lo siguiente:
Console
Cuando usas la consola de Google Cloud para crear una clave, Cloud KMS establece automáticamente el período de rotación y la próxima fecha de rotación. Puedes optar por usar los valores predeterminados o especificar valores diferentes.
Para especificar un período de rotación y tiempo de inicio diferentes, cuando estés creando tu clave, pero antes de hacer clic el botón Crear:
En Período de rotación de claves, selecciona una opción.
En A partir del, selecciona la fecha en la que quieres que se realice la primera para que ocurra la rotación. Puedes dejar A partir del con su valor predeterminado: inicie la primera rotación automática un período de rotación de claves a partir del crea la clave.
gcloud
Para usar Cloud KMS en la línea de comandos, primero Instala o actualiza a la versión más reciente de Google Cloud CLI.
gcloud kms keys create KEY_NAME \ --keyring KEY_RING \ --location LOCATION \ --purpose "encryption" \ --rotation-period ROTATION_PERIOD \ --next-rotation-time NEXT_ROTATION_TIME
Reemplaza lo siguiente:
KEY_NAME
: el nombre de la clave.KEY_RING
: Es el nombre del llavero de claves que contiene la clave.LOCATION
: Es la ubicación de Cloud KMS del llavero de claves.ROTATION_PERIOD
: Es el intervalo para rotar la clave, por ejemplo,30d
para rotar la clave cada 30 días. La rotación el período debe ser de 1 día como mínimo y 100 años como máximo. Para obtener más información, consulta CryptoKey.rotationPeriod.NEXT_ROTATION_TIME
: La marca de tiempo en la que se completará la primera rotación, por ejemplo,"2023-01-01T01:02:03"
. Puedes omitir--next-rotation-time
para programar la primera rotación durante 7 días a partir de la fecha en la que ejecutas el comando. Para obtener más información, consulta CryptoKey.nextRotationTime.
Para obtener información sobre todas las marcas y los valores posibles, ejecuta el comando con la marca --help
.
C#
Para ejecutar este código, primero configura un entorno de desarrollo de C# e instala el SDK de C# para Cloud KMS.
Go
Para ejecutar este código, primero configura un entorno de desarrollo de Go y, luego, instala el SDK de Go para Cloud KMS.
Java
Para ejecutar este código, primero configura un entorno de desarrollo de Java y, luego, instala el SDK de Java para Cloud KMS.
Node.js
Para ejecutar este código, primero configura un entorno de desarrollo de Node.js y, luego, instala el SDK de Node.js para Cloud KMS.
PHP
Para ejecutar este código, primero obtén información sobre cómo usar PHP en Google Cloud y, luego, instala el SDK de PHP para Cloud KMS.
Python
Para ejecutar este código, primero configura un entorno de desarrollo de Python y, luego, instala el SDK de Python para Cloud KMS.
Ruby
Para ejecutar este código, primero configura un entorno de desarrollo de Ruby y, luego, instala el SDK de Ruby para Cloud KMS.
API
En estos ejemplos, se usa curl como un cliente HTTP para demostrar el uso de la API. Para obtener más información sobre el control de acceso, consulta Accede a la API de Cloud KMS.
Para crear una clave, usa el
CryptoKey.create
método:
curl "https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys?crypto_key_id=KEY_NAME" \ --request "POST" \ --header "authorization: Bearer TOKEN" \ --header "content-type: application/json" \ --data '{"purpose": "PURPOSE", "rotationPeriod": "ROTATION_PERIOD", "nextRotationTime": "NEXT_ROTATION_TIME"}'
Reemplaza lo siguiente:
PURPOSE
: Es el propósito de la clave.ROTATION_PERIOD
: Es el intervalo para rotar la clave, por ejemplo,30d
para rotar la clave cada 30 días. La rotación el período debe ser de 1 día como mínimo y 100 años como máximo. Para obtener más información, consulta CryptoKey.rotationPeriod.NEXT_ROTATION_TIME
: La marca de tiempo en la que se debe completar la primera rotación, por ejemplo,"2023-01-01T01:02:03"
. Puedes omitir--next-rotation-time
para programar la primera rotación durante 7 días a partir de la fecha en que ejecutes la kubectl. Para obtener más información, consulta CryptoKey.nextRotationTime.
Para configurar la rotación automática en una clave existente, haz lo siguiente:
Console
Ve a la página Administración de claves en la consola de Google Cloud.
Haz clic en el nombre del llavero de claves que contiene la clave para la que quieres agregar un programa de rotación.
Haz clic en la clave a la que deseas agregar un programa de rotación.
En el encabezado, haz clic en Editar período de rotación.
En el mensaje, elige valores nuevos para los campos Período de rotación y A partir de.
En la ventana, haz clic en Guardar.
gcloud
Para usar Cloud KMS en la línea de comandos, primero Instala o actualiza a la versión más reciente de Google Cloud CLI.
gcloud kms keys update KEY_NAME \ --location LOCATION \ --keyring KEY_RING \ --rotation-period ROTATION_PERIOD \ --next-rotation-time NEXT_ROTATION_TIME
Reemplaza lo siguiente:
KEY_NAME
: el nombre de la clave.KEY_RING
: Es el nombre del llavero de claves que contiene la clave.LOCATION
: Es la ubicación de Cloud KMS del llavero de claves.ROTATION_PERIOD
: el intervalo para rotar la clave, por ejemplo,30d
para rotar la clave cada 30 días La rotación el período debe ser de 1 día como mínimo y 100 años como máximo. Para obtener más información, consulta CryptoKey.rotationPeriod.NEXT_ROTATION_TIME
: La marca de tiempo en la que se completará la primera rotación, por ejemplo,"2023-01-01T01:02:03"
. Puedes omitir--next-rotation-time
para programar la primera rotación durante 7 días a partir de la fecha en que ejecutes la kubectl. Para obtener más información, consulta CryptoKey.nextRotationTime.
Para obtener información sobre todas las marcas y los valores posibles, ejecuta el comando con la marca --help
.
C#
Para ejecutar este código, primero configura un entorno de desarrollo de C# e instala el SDK de C# para Cloud KMS.
Go
Para ejecutar este código, primero configura un entorno de desarrollo de Go y, luego, instala el SDK de Go para Cloud KMS.
Java
Para ejecutar este código, primero configura un entorno de desarrollo de Java y, luego, instala el SDK de Java para Cloud KMS.
Node.js
Para ejecutar este código, primero configura un entorno de desarrollo de Node.js y, luego, instala el SDK de Node.js para Cloud KMS.
PHP
Para ejecutar este código, primero obtén información sobre cómo usar PHP en Google Cloud y, luego, instala el SDK de PHP para Cloud KMS.
Python
Para ejecutar este código, primero configura un entorno de desarrollo de Python y, luego, instala el SDK de Python para Cloud KMS.
Ruby
Para ejecutar este código, primero configura un entorno de desarrollo de Ruby y, luego, instala el SDK de Ruby para Cloud KMS.
API
En estos ejemplos, se usa curl como un cliente HTTP para demostrar el uso de la API. Para obtener más información sobre el control de acceso, consulta Accede a la API de Cloud KMS.
Para actualizar una clave, usa la
CryptoKey.patch
método:
curl "https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME?updateMask=rotationPeriod,nextRotationTime" \ --request "PATCH" \ --header "authorization: Bearer TOKEN" \ --header "content-type: application/json" \ --data '{"rotationPeriod": "ROTATION_PERIOD", "nextRotationTime": "NEXT_ROTATION_TIME"}'
Reemplaza lo siguiente:
ROTATION_PERIOD
: el intervalo para rotar la clave, por ejemplo,30d
para rotar la clave cada 30 días La rotación el período debe ser de 1 día como mínimo y 100 años como máximo. Para obtener más información, consulta CryptoKey.rotationPeriod.NEXT_ROTATION_TIME
: La marca de tiempo en la que se debe completar la primera rotación, por ejemplo,"2023-01-01T01:02:03"
. Puedes omitir--next-rotation-time
para programar la primera rotación durante 7 días a partir de la fecha en que ejecutes la kubectl. Para obtener más información, consulta CryptoKey.nextRotationTime.
Rota una clave de forma manual
Primero, crea una versión de clave nueva:
Console
Ve a la página Administración de claves en la consola de Google Cloud.
Haz clic en el nombre del llavero de claves que contiene la clave para la que crearás una versión de clave nueva.
Haz clic en la clave para la que crearás una versión de clave nueva.
En el encabezado, haz clic en Rotar.
En el mensaje, haz clic en Rotar para confirmar.
gcloud
Para usar Cloud KMS en la línea de comandos, primero Instala o actualiza a la versión más reciente de Google Cloud CLI.
gcloud kms keys versions create \ --key KEY_NAME \ --keyring KEY_RING \ --location LOCATION
Reemplaza lo siguiente:
KEY_NAME
: el nombre de la clave.KEY_RING
: Es el nombre del llavero de claves que contiene la clave.LOCATION
: Es la ubicación de Cloud KMS del llavero de claves.
A las versiones de claves se les asigna un número de manera secuencial.
Para obtener información sobre todas las marcas y los valores posibles, ejecuta el comando con la marca --help
.
C#
Para ejecutar este código, primero configura un entorno de desarrollo de C# e instala el SDK de C# para Cloud KMS.
Go
Para ejecutar este código, primero configura un entorno de desarrollo de Go y, luego, instala el SDK de Go para Cloud KMS.
Java
Para ejecutar este código, primero configura un entorno de desarrollo de Java y, luego, instala el SDK de Java para Cloud KMS.
Node.js
Para ejecutar este código, primero configura un entorno de desarrollo de Node.js y, luego, instala el SDK de Node.js para Cloud KMS.
PHP
Para ejecutar este código, primero obtén información sobre cómo usar PHP en Google Cloud y, luego, instala el SDK de PHP para Cloud KMS.
Python
Para ejecutar este código, primero configura un entorno de desarrollo de Python y, luego, instala el SDK de Python para Cloud KMS.
Ruby
Para ejecutar este código, primero configura un entorno de desarrollo de Ruby y, luego, instala el SDK de Ruby para Cloud KMS.
API
En estos ejemplos, se usa curl como un cliente HTTP para demostrar el uso de la API. Para obtener más información sobre el control de acceso, consulta Accede a la API de Cloud KMS.
Para rotar una clave manualmente, primero crea una nueva versión de clave llamando al CryptoKeyVersions.create .
curl "https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME/cryptoKeyVersions" \ --request "POST" \ --header "authorization: Bearer TOKEN"
Este comando crea una versión de clave nueva, pero no la establece como la versión principal.
Para establecer tu nueva versión de clave como principal, consulta Configura una versión existente como la versión de clave primaria.
Si es necesario, vuelve a encriptar los datos que se encriptaron con la versión de clave anterior.
Establece una versión existente como la versión de clave primaria
A fin de establecer una versión de clave diferente como la versión principal de una clave, actualízala con la nueva información de la versión principal. Se debe habilitar una versión de clave antes de configurarla como la versión principal.
Console
Ve a la página Administración de claves en la consola de Google Cloud.
Haz clic en el nombre del llavero de claves que contiene la clave cuya versión principal deseas actualizar.
Haz clic en la clave cuya versión principal deseas actualizar.
En la fila correspondiente a la versión de clave que deseas convertir en principal, haz clic en Ver más
.Haz clic en Crear versión principal en el menú.
En el mensaje de confirmación, haz clic en Convertir en principal.
gcloud
Para usar Cloud KMS en la línea de comandos, primero Instala o actualiza a la versión más reciente de Google Cloud CLI.
gcloud kms keys update KEY_NAME \ --keyring KEY_RING \ --location LOCATION \ --primary-version KEY_VERSION
Reemplaza lo siguiente:
KEY_NAME
: el nombre de la clave.KEY_RING
: Es el nombre del llavero de claves que contiene la clave.LOCATION
: Es la ubicación de Cloud KMS del llavero de claves.- KEY_VERSION: Es el número de versión de la versión de clave primaria nueva.
Para obtener información sobre todas las marcas y los valores posibles, ejecuta el comando con la marca --help
.
C#
Para ejecutar este código, primero configura un entorno de desarrollo de C# e instala el SDK de C# para Cloud KMS.
Go
Para ejecutar este código, primero configura un entorno de desarrollo de Go y, luego, instala el SDK de Go para Cloud KMS.
Java
Para ejecutar este código, primero configura un entorno de desarrollo de Java y, luego, instala el SDK de Java para Cloud KMS.
Node.js
Para ejecutar este código, primero configura un entorno de desarrollo de Node.js y, luego, instala el SDK de Node.js para Cloud KMS.
PHP
Para ejecutar este código, primero obtén información sobre cómo usar PHP en Google Cloud y, luego, instala el SDK de PHP para Cloud KMS.
Ruby
Para ejecutar este código, primero configura un entorno de desarrollo de Ruby y, luego, instala el SDK de Ruby para Cloud KMS.
Python
Para ejecutar este código, primero configura un entorno de desarrollo de Python y, luego, instala el SDK de Python para Cloud KMS.
API
En estos ejemplos, se usa curl como un cliente HTTP para demostrar el uso de la API. Para obtener más información sobre el control de acceso, consulta Accede a la API de Cloud KMS.
Para cambiar la versión de la clave primaria, llama al método CryptoKey.updatePrimaryVersion.
curl "https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME:updatePrimaryVersion" \ --request "POST" \ --header "authorization: Bearer TOKEN" \ --header "content-type: application/json" \ --data '{"cryptoKeyVersionId": "KEY_VERSION"}'
Reemplaza lo siguiente:
PROJECT_ID
: El ID del proyecto que contiene el llavero.LOCATION
: Es la ubicación de Cloud KMS del llavero de claves.KEY_RING
: Es el nombre del llavero de claves que contiene la clave.KEY_NAME
: el nombre de la clave.- KEY_VERSION: Es el número de versión de la versión de clave primaria nueva.
Cuando cambias la versión de clave primaria, el cambio suele ser coherente en 1 minuto. Sin embargo, este cambio puede tardar hasta 3 horas en propagarse en casos excepcionales. Durante este tiempo, es posible que se use la versión principal anterior para encriptar los datos. Para obtener más información, consulta Coherencia de recursos de Cloud KMS.
Inhabilita la rotación automática
Para inhabilitar la rotación automática de una clave, borra el programa de rotación de la clave:
Console
Ve a la página Administración de claves en la consola de Google Cloud.
Haz clic en el nombre del llavero de claves que contiene la clave para la que quieres quitar el programa de rotación.
Haz clic en la clave a la que deseas quitar el programa de rotación.
En el encabezado, haz clic en Editar período de rotación.
En el mensaje, haz clic en el campo Período de rotación y selecciona Nunca. (rotación manual).
En la ventana, haz clic en Guardar.
gcloud
Para usar Cloud KMS en la línea de comandos, primero Instala o actualiza a la versión más reciente de Google Cloud CLI.
gcloud kms keys update KEY_NAME \ --keyring KEY_RING \ --location LOCATION \ --remove-rotation-schedule
Reemplaza lo siguiente:
KEY_NAME
: el nombre de la clave.KEY_RING
: Es el nombre del llavero de claves que contiene la clave.LOCATION
: Es la ubicación de Cloud KMS del llavero de claves.
Para obtener información sobre todas las marcas y los valores posibles, ejecuta el comando con la marca --help
.
C#
Para ejecutar este código, primero configura un entorno de desarrollo de C# e instala el SDK de C# para Cloud KMS.
Go
Para ejecutar este código, primero configura un entorno de desarrollo de Go y, luego, instala el SDK de Go para Cloud KMS.
Java
Para ejecutar este código, primero configura un entorno de desarrollo de Java y, luego, instala el SDK de Java para Cloud KMS.
Node.js
Para ejecutar este código, primero configura un entorno de desarrollo de Node.js y, luego, instala el SDK de Node.js para Cloud KMS.
PHP
Para ejecutar este código, primero obtén información sobre cómo usar PHP en Google Cloud y, luego, instala el SDK de PHP para Cloud KMS.
Ruby
Para ejecutar este código, primero configura un entorno de desarrollo de Ruby y, luego, instala el SDK de Ruby para Cloud KMS.
Python
Para ejecutar este código, primero configura un entorno de desarrollo de Python y, luego, instala el SDK de Python para Cloud KMS.
API
En estos ejemplos, se usa curl como un cliente HTTP para demostrar el uso de la API. Para obtener más información sobre el control de acceso, consulta Accede a la API de Cloud KMS.
Para actualizar una clave, usa la
CryptoKey.patch
método:
curl "https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME?updateMask=rotationPeriod,nextRotationTime" \ --request "PATCH" \ --header "authorization: Bearer TOKEN" \ --header "content-type: application/json" \ --data '{"rotationPeriod": null, "nextRotationTime": null}'
Para obtener información adicional sobre rotationPeriod
y nextRotationTime
, consulta
keyRings.cryptoKeys
Rota una clave externa
Rota una clave externa coordinada
Puedes configurar la rotación automática para claves externas simétricas coordinadas. También puedes crear una versión de clave nueva de forma manual para claves externas simétricas o asimétricas coordinadas.
Si rotas o creas una versión de clave nueva, todos los datos recién creados que se protejan con esa clave se encriptarán con la versión nueva. Datos protegidos con una versión anterior de la clave no se vuelve a encriptar. Como resultado, tu administrador de claves externo debe seguir haciendo que el material de clave de la versión de clave anterior esté disponible para su uso.
Para crear una versión de clave nueva para una clave externa coordinada, completa los siguientes pasos:
Console
En la consola de Google Cloud, ve a Administración de claves.
Selecciona el llavero de claves y, luego, la clave.
Haz clic en Crear versión. Un mensaje indica que la versión de clave nueva se generarán en Cloud KMS y en tu EKM. Si ves un mensaje Ruta de acceso de la clave o URI de la clave, la clave seleccionada no está coordinada clave externa.
Para confirmar que quieres crear una versión de clave nueva, haz clic en Crear versión.
La versión de clave nueva aparece en el estado Generación pendiente. Para simétrico claves, las versiones de claves creadas de forma manual no se establecen como versión de clave primaria. Puedes configurar la nueva versión de clave como primaria.
gcloud CLI
Para crear una nueva versión de clave simétrica y establecerla como la versión de clave principal, usa el comando kms keys versions create
con la marca --primary
:
gcloud kms keys versions create \ --key KEY_NAME \ --keyring KEY_RING \ --location LOCATION \ --primary
Reemplaza lo siguiente:
KEY_NAME
: el nombre de la clave.KEY_RING
: Es el nombre del llavero de claves que contiene la clave.LOCATION
: Es la ubicación de Cloud KMS del llavero de claves.
Crea una versión de clave asimétrica nueva o una clave simétrica nueva
que no sea la versión de clave primaria, usa el comando kms keys versions
create
:
gcloud kms keys versions create \ --key KEY_NAME \ --keyring KEY_RING \ --location LOCATION
Reemplaza lo siguiente:
KEY_NAME
: el nombre de la clave.KEY_RING
: Es el nombre del llavero de claves que contiene la clave.LOCATION
: Es la ubicación de Cloud KMS del llavero de claves.
Rota un Cloud EKM administrado manualmente a través de una clave de VPC
Primero, rota el material de clave externo en tu administrador de claves externo. Si eso se genera una ruta de clave nueva, debes rotar o crear un nuevo Cloud EKM a la versión de clave con la ruta de acceso de la clave nueva. Para las claves de encriptación simétrica, rota la clave de Cloud EKM y especifica la nueva ruta de acceso de la clave desde tu administrador de claves externo. En el caso de las claves asimétricas, crea una versión de clave nueva y especifica la nueva ruta de acceso a la clave.
Rotar o crear una versión de clave nueva hace que todos los datos recién creados estén protegidos para encriptarlos con la versión de clave nueva. Los datos protegidos con una versión de clave anterior no se vuelven a encriptar. Como resultado, tu clave externa administrador debe continuar creando el material de claves de la versión de clave anterior disponibles para usar.
Si el material de clave en el sistema de administración de claves externas no cambia, cambios en la ruta de acceso, puedes actualizar la configuración path sin rotar la clave.
Console
En la consola de Google Cloud, ve a Administración de claves.
Selecciona el llavero de claves y, luego, la clave.
Haz clic en Rotar clave.
En Key path, ingresa la ruta de la clave para la versión nueva.
Haz clic en Rotar clave para confirmar.
gcloud
Para usar Cloud KMS en la línea de comandos, primero Instala o actualiza a la versión más reciente de Google Cloud CLI.
Para crear una versión de clave simétrica nueva y establecerla como la versión de clave primaria, haz lo siguiente:
usa el comando kms keys versions create
con la marca --primary
:
gcloud kms keys versions create \ --key KEY_NAME \ --keyring KEY_RING \ --location LOCATION \ --ekm-connection-key-path EXTERNAL_KEY_PATH \ --primary
Reemplaza lo siguiente:
KEY_NAME
: el nombre de la clave.KEY_RING
: Es el nombre del llavero de claves que contiene la clave.LOCATION
: Es la ubicación de Cloud KMS del llavero de claves.EXTERNAL_KEY_PATH
: Es la ruta de acceso al nuevo recurso externo. y la versión de clave.
Crea una versión de clave asimétrica nueva o una clave simétrica nueva
que no sea la versión de clave primaria, usa el comando kms keys versions
create
:
gcloud kms keys versions create \ --key KEY_NAME \ --keyring KEY_RING \ --location LOCATION \ --ekm-connection-key-path EXTERNAL_KEY_PATH
Reemplaza lo siguiente:
KEY_NAME
: el nombre de la clave.KEY_RING
: Es el nombre del llavero de claves que contiene la clave.LOCATION
: Es la ubicación de Cloud KMS del llavero de claves.EXTERNAL_KEY_PATH
: Es la ruta de acceso al nuevo recurso externo. y la versión de clave.
Para obtener información sobre todas las marcas y los valores posibles, ejecuta el comando con la marca --help
.
Una vez que la versión de clave se crea correctamente, puedes usarla como lo harías usar cualquier otra versión de clave de Cloud KMS.
Rota un Cloud EKM administrado manualmente a través de una clave de Internet
Primero, rota el material de clave externa en tu administrador de claves externo. Si eso genera un nuevo URI, debes rotar o crear una nueva clave de Cloud EKM con el nuevo URI. Para claves de encriptación simétricas, rotate el objeto Clave de Cloud EKM y especifica el URI de la clave nueva de tu clave externa administrador. En el caso de las claves asimétricas, crea una versión de clave nueva y especifica la clave nueva URI
Rotar o crear una versión de clave nueva hace que todos los datos recién creados estén protegidos para encriptarlos con la versión de clave nueva. Datos protegidos con una versión anterior de la clave no se vuelve a encriptar. Como resultado, tu clave externa de claves debe continuar creando el material de claves de la versión de clave anterior disponibles para su uso.
Si el material de clave en el sistema de administración de claves externas no cambia, pero el URI cambios, puedes actualizar la configuración URI sin rotar la clave.
Console
En la consola de Google Cloud, ve a Administración de claves.
Selecciona el llavero de claves y, luego, la clave.
Selecciona Rotar clave para claves simétricas o Crear versión para claves asimétricas.
Ingresa el URI de la nueva clave y, luego, selecciona Rotar clave para las claves simétricas. Crea una versión para claves asimétricas.
La versión de clave nueva se convertirá en la versión principal.
gcloud CLI
Para crear una nueva versión de clave simétrica y establecerla como la versión de clave principal, usa el comando kms keys versions create
con la marca --primary
:
gcloud kms keys versions create \ --key KEY_NAME \ --keyring KEY_RING \ --location LOCATION \ --external-key-uri EXTERNAL_KEY_URI \ --primary
Reemplaza lo siguiente:
KEY_NAME
: el nombre de la clave.KEY_RING
: Es el nombre del llavero de claves que contiene la clave.LOCATION
: Es la ubicación de Cloud KMS del llavero de claves.EXTERNAL_KEY_URI
: Es el URI de clave de la nueva versión de clave externa.
Crea una versión de clave asimétrica nueva o una clave simétrica nueva
que no sea la versión de clave primaria, usa el comando kms keys versions
create
:
gcloud kms keys versions create \ --key KEY_NAME \ --keyring KEY_RING \ --location LOCATION \ --external-key-uri EXTERNAL_KEY_URI
Reemplaza lo siguiente:
KEY_NAME
: el nombre de la clave.KEY_RING
: Es el nombre del llavero de claves que contiene la clave.LOCATION
: Es la ubicación de Cloud KMS del llavero de claves.EXTERNAL_KEY_URI
: El URI de la clave del nuevo externo y la versión de clave.