MongoDB\Driver\ClientEncryption::createDataKey

(mongodb >=1.7.0)

MongoDB\Driver\ClientEncryption::createDataKeyCreates a key document

Description

finalpublicMongoDB\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
OptionTypeDescription
masterKeyarray

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"
OptionTypeDescription
regionstringRequis.
keystringRequis. Le nom de ressource Amazon (ARN) de la clé maîtresse du client AWS (CMK).
endpointstringOptionnel. Un identifiant d'hôte alternatif pour envoyer les demandes KMS. Peut inclure le numéro de port.

Options du fournisseur "azure"
OptionTypeDescription
keyVaultEndpointstringRequis. Hôte avec port optionnel (par exemple, "example.vault.azure.net").
keyNamestringRequis.
keyVersionstringOptionnel. 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"
OptionTypeDescription
projectIdstringRequis.
locationstringRequis.
keyRingstringRequis.
keyNamestringRequis.
keyVersionstringOptionnel. Une version spécifique de la clé nommée. Par défaut, la version primaire de la clé est utilisée.
endpointstringOptionnel. Hôte avec port optionnel. La valeur par défaut est "cloudkms.googleapis.com".

Options du fournisseur "kmip"
OptionTypeDescription
keyIdstringOptionnel. 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.
endpointstringOptionnel. Hôte avec port optionnel.
keyAltNamesarray

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.

keyMaterialMongoDB\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

VersionDescription
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.
To Top