Skip to content

Commit 13a2edd

Browse files
RUBY-2405 Add GCP KMS support (#2374)
1 parent ab04b38 commit 13a2edd

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

source/reference/client-side-encryption.txt

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ Both automatic encryption and explicit encryption require an encryption master k
305305
This master key is used to encrypt data keys, which are in turn used to encrypt
306306
user data. The master key can be generated in one of two ways: by creating a
307307
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).
309310

310311
Local Master Key
311312
~~~~~~~~~~~~~~~~
@@ -380,7 +381,7 @@ See the `Local Master Key`_ section for more information about generating a new
380381
local master key.
381382

382383
Create a Data Key Using a Remote Master Key
383-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384385

385386
If you have created an AWS KMS master key, note the access key ID and the secret access
386387
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.
389390

390391
If you have created an Azure master key, note the tenant id, the client id, and
391392
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
393394
for your master key. You will use that information to generate a data key.
394395

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+
395407
.. code-block:: ruby
396408

397409
# 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.
412424
tenant_id: 'AZURE-TENANT-ID',
413425
client_id: 'AZURE-CLIENT-ID',
414426
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',
415433
}
416434
}
417435
)
@@ -423,7 +441,6 @@ for your master key. You will use that information to generate a data key.
423441
region: 'REGION-OF-YOUR-MASTER-KEY',
424442
key: 'ARN-OF-YOUR-MASTER-KEY'
425443
}
426-
427444
}
428445
)
429446
# => <BSON::Binary... type=ciphertext...>
@@ -435,7 +452,19 @@ for your master key. You will use that information to generate a data key.
435452
key_vault_endpoint: 'AZURE-KEY-VAULT-ENDPOINT',
436453
key_name: 'AZURE-KEY-NAME'
437454
}
455+
}
456+
)
457+
# => <BSON::Binary... type=ciphertext...>
438458

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+
}
439468
}
440469
)
441470
# => <BSON::Binary... type=ciphertext...>

0 commit comments

Comments
 (0)