CakeFest 2024: The Official CakePHP Conference

MongoDB\Driver\ClientEncryption::createDataKey

(mongodb >=1.7.0)

MongoDB\Driver\ClientEncryption::createDataKeyCreates a key document

Description

final public MongoDB\Driver\ClientEncryption::createDataKey(string $kmsProvider, ?array $options = null): MongoDB\BSON\Binary

Creates a new key document and inserts it into the key vault collection.

Liste de paramètres

kmsProvider

The KMS provider (e.g. "local", "aws") that will be used to encrypt the new data key.

options

Data key options
Option Type Description
masterKey array

The masterKey document identifies a KMS-specific key used to encrypt the new data key. This option is required unless kmsProvider is "local".

Options du fournisseur "aws"
Option Type Description
region string Requis.
key string Requis. Le nom de ressource Amazon (ARN) de la clé maîtresse du client AWS (CMK).
endpoint string Optionnel. Un identifiant d'hôte alternatif pour envoyer les demandes KMS. Peut inclure le numéro de port.

Options du fournisseur "azure"
Option Type Description
keyVaultEndpoint string Requis. Hôte avec port optionnel (par exemple, "example.vault.azure.net").
keyName string Requis.
keyVersion string Optionnel. Une version spécifique de la clé nommée. Par défaut, la version primaire de la clé est utilisée.

Options du fournisseur "gcp"
Option Type Description
projectId string Requis.
location string Requis.
keyRing string Requis.
keyName string Requis.
keyVersion string Optionnel. Une version spécifique de la clé nommée. Par défaut, la version primaire de la clé est utilisée.
endpoint string Optionnel. Hôte avec port optionnel. La valeur par défaut est "cloudkms.googleapis.com".

Options du fournisseur "kmip"
Option Type Description
keyId string Optionnel. Identifiant unique d'un objet géré de 96 octets de données secrètes KMIP. S'il n'est pas spécifié, le pilote crée un objet géré aléatoire de 96 octets de données secrètes KMIP.
endpoint string Optionnel. Hôte avec port optionnel.

keyAltNames array

An optional list of string alternate names used to reference a key. If a key is created with alternate names, then encryption may refer to the key by the unique alternate name instead of by _id.

keyMaterial MongoDB\BSON\Binary

An optional 96-byte value to use as custom key material for the data key being created. If keyMaterial is given, the custom key material is used for encrypting and decrypting data. Otherwise, the key material for the new data key is generated from a cryptographically secure random device.

Valeurs de retour

Returns the identifier of the new key as a MongoDB\BSON\Binary object with subtype 4 (UUID).

Erreurs / Exceptions

  • Lance une exception MongoDB\Driver\AuthenticationException si une identification est nécessaire mais qu'elle échoue
  • Lance une exception MongoDB\Driver\ConnectionException si la connexion au serveur échoue pour une autre raison qu'en raison d'un problème d'identification
  • Throws MongoDB\Driver\Exception\RuntimeException on other errors.

Historique

Version Description
PECL mongodb 1.15.0 Added the "keyMaterial" option.
PECL mongodb 1.10.0 Azure and GCP are now supported as KMS providers for client-side encryption.

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top