@@ -305,7 +305,8 @@ Both automatic encryption and explicit encryption require an encryption master k
305
305
This master key is used to encrypt data keys, which are in turn used to encrypt
306
306
user data. The master key can be generated in one of two ways: by creating a
307
307
local key, or by creating a key in a key management service. Currently
308
- Ruby driver supports AWS Key Management Service (KMS) and Azure Key Vault.
308
+ Ruby driver supports AWS Key Management Service (KMS), Azure Key Vault, and
309
+ Google Cloud Key Management (GCP KMS).
309
310
310
311
Local Master Key
311
312
~~~~~~~~~~~~~~~~
@@ -380,7 +381,7 @@ See the `Local Master Key`_ section for more information about generating a new
380
381
local master key.
381
382
382
383
Create a Data Key Using a Remote Master Key
383
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384
385
385
386
If you have created an AWS KMS master key, note the access key ID and the secret access
386
387
key of the IAM user that has permissions to use the key. Additionally, note
@@ -389,9 +390,20 @@ use that information to generate a data key.
389
390
390
391
If you have created an Azure master key, note the tenant id, the client id, and
391
392
the client secret of the application that has permissions to use the key.
392
- Additionally, note the key name, key version (id any), and key vault endpoint
393
+ Additionally, note the key name, key version (if any), and key vault endpoint
393
394
for your master key. You will use that information to generate a data key.
394
395
396
+ If you have created a GCP KMS master key, note the email and the private key,
397
+ and the client secret of the application that has permissions to use the key.
398
+ Additionally, note the project id, location, key ring, key name, and
399
+ key version (if any) for your master key. You will use that information to
400
+ generate a data key.
401
+
402
+ Please note that GCP private key can be in different formats. Ruby driver
403
+ supports DER encoded RSA private key as base64 encoded string. For MRI Ruby
404
+ the driver additionally support PEM encoded RSA private key.
405
+
406
+
395
407
.. code-block:: ruby
396
408
397
409
# A Mongo::Client instance that will be used to connect to the key vault
@@ -412,6 +424,12 @@ for your master key. You will use that information to generate a data key.
412
424
tenant_id: 'AZURE-TENANT-ID',
413
425
client_id: 'AZURE-CLIENT-ID',
414
426
client_secret: 'AZURE-CLIENT-SECRET'
427
+ },
428
+ gcp: {
429
+ email: 'GCP-EMAIL',
430
+ # :private_key value should be GCP private key as base64 encoded
431
+ # DER RSA private key, or PEM RSA private key, if you are using MRI Ruby.
432
+ private_key: 'GCP-PRIVATE-KEY',
415
433
}
416
434
}
417
435
)
@@ -423,7 +441,6 @@ for your master key. You will use that information to generate a data key.
423
441
region: 'REGION-OF-YOUR-MASTER-KEY',
424
442
key: 'ARN-OF-YOUR-MASTER-KEY'
425
443
}
426
-
427
444
}
428
445
)
429
446
# => <BSON::Binary... type=ciphertext...>
@@ -435,7 +452,19 @@ for your master key. You will use that information to generate a data key.
435
452
key_vault_endpoint: 'AZURE-KEY-VAULT-ENDPOINT',
436
453
key_name: 'AZURE-KEY-NAME'
437
454
}
455
+ }
456
+ )
457
+ # => <BSON::Binary... type=ciphertext...>
438
458
459
+ gcp_data_key_id = client_encryption.create_data_key(
460
+ 'gcp',
461
+ {
462
+ master_key: {
463
+ project_id: 'GCP-PROJECT-ID',
464
+ location: 'GCP-LOCATION',
465
+ key_ring: 'GCP-KEY-RING',
466
+ key_name: 'GCP-KEY-NAME',
467
+ }
439
468
}
440
469
)
441
470
# => <BSON::Binary... type=ciphertext...>
0 commit comments