Skip to content

CDRIVER-4206 KMIP support #881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 93 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
1c8d9db
add failing kmsKMIP test
kevinAlbs Oct 14, 2021
0b42575
get kmsKMIP test passing with hardcoded TLS options
kevinAlbs Oct 15, 2021
f9e52a4
CDRIVER-4087 document Azure and GCP KMS providers
kevinAlbs Oct 15, 2021
6a5e42c
fix URI documentation, include "FILE" in MONGOC_URI_TLSCERTIFICATEKEY…
kevinAlbs Oct 15, 2021
66a7742
document "kmip" KMS provider opts
kevinAlbs Oct 15, 2021
413ddf4
SCAFFOLDING - debug log each ctx state
kevinAlbs Oct 15, 2021
2513fa5
parse kmip.tls from KMS providers, and use for TLS streams to kmip
kevinAlbs Oct 15, 2021
d7bdada
add MONGOC_TEST_KMIP_TLS_CA_FILE
kevinAlbs Oct 15, 2021
90b3a87
fix leak in _parse_kms_providers
kevinAlbs Oct 15, 2021
a9dcb0e
add datakey/double encryption + custom endpoint prose tests
kevinAlbs Oct 16, 2021
cfe8446
add corpus tests
kevinAlbs Oct 19, 2021
98b2b94
WIP: add KMIP server to run kms servers
kevinAlbs Oct 19, 2021
1e6133c
WIP: use kevinAlbs/libmongocrypt
kevinAlbs Oct 19, 2021
e8ab473
WIP: add env vars to run KMIP tests
kevinAlbs Oct 19, 2021
2aadc55
add more error logs
kevinAlbs Oct 19, 2021
d8d84af
TEMP: faster compile-unix.sh
kevinAlbs Oct 19, 2021
82d5e6f
TEMP: fix test subselector
kevinAlbs Oct 19, 2021
a79042b
TEMP: add more logging
kevinAlbs Oct 19, 2021
8433381
run only kmipKMS
kevinAlbs Oct 19, 2021
bfe5247
fix windows BUILD_VERSION
kevinAlbs Oct 19, 2021
ca6175f
add sleep for KMS server
kevinAlbs Oct 19, 2021
4254ba0
TEMP: increase timeout
kevinAlbs Oct 19, 2021
03dc47d
add fflush to MONGOC_DEBUG
kevinAlbs Oct 19, 2021
6a040b8
TEMP add --no-fork to windows
kevinAlbs Oct 19, 2021
38a66c2
skip mock tests on windows
kevinAlbs Oct 19, 2021
a778713
run all client_side_encryption tests; use wait_for_kms_server
kevinAlbs Oct 19, 2021
62089d4
update evg python scripts
kevinAlbs Oct 20, 2021
f216ddb
update corpus-encrypted from specifications repo
kevinAlbs Oct 20, 2021
a8291ec
use default_ports.352 branch
kevinAlbs Oct 27, 2021
5875569
use default_ports.352 on Windows
kevinAlbs Oct 27, 2021
e7cb25c
remove default port logic
kevinAlbs Oct 27, 2021
4954616
update Custom Endpoint test 11 and add test 12
kevinAlbs Oct 30, 2021
7ff60fe
add KMIP TLS options prose test
kevinAlbs Nov 1, 2021
531e3e3
add failing TLS options test
kevinAlbs Nov 2, 2021
b6e7697
remove redundant test_kmip_tls_options
kevinAlbs Nov 2, 2021
7170f0a
update auto encryption and client encryption docs to add TLS options …
kevinAlbs Nov 2, 2021
e06cb22
support TLS options in AWS, Azure, and GCP
kevinAlbs Nov 3, 2021
c290ae2
add mock_kms_server on port 8002 to evg
kevinAlbs Nov 3, 2021
5550429
update test_kms_tls_options
kevinAlbs Nov 3, 2021
6d972fd
remove default_ports branch workaround
kevinAlbs Nov 3, 2021
6b0e4f8
remove error messages for TLS handshake errors
kevinAlbs Nov 3, 2021
c9bdc92
add back temporarily removed tests
kevinAlbs Nov 3, 2021
11872e5
remove test case 5 from TLS Options tests
kevinAlbs Nov 3, 2021
6b29e41
skip TLS Options tests on Windows due to CDRIVER-4181
kevinAlbs Nov 3, 2021
1261fa1
add expired and invalid hostname cases
kevinAlbs Nov 4, 2021
201ddf3
add wait_for_kms_server on port 8002
kevinAlbs Nov 4, 2021
c0ad0e0
add stub API and docs for mongoc_auto_encryption_opts_set_tls_opts an…
kevinAlbs Nov 7, 2021
8a52b71
move examples to client-side-encryption-doc-snippets
kevinAlbs Nov 7, 2021
7e53b06
add failing unit test
kevinAlbs Nov 7, 2021
2b6d448
implement set_tls_opts
kevinAlbs Nov 7, 2021
8184766
remove dead code
kevinAlbs Nov 7, 2021
966890b
update tests to use new set_tls_opts helpers
kevinAlbs Nov 7, 2021
09db02d
use mongodb-labs/drivers-evergreen-tools now that mock KMIP server ch…
kevinAlbs Nov 7, 2021
8f1c10b
fix leak
kevinAlbs Nov 7, 2021
b7d5452
remove MONGOC_TEST_KMIP_ENDPOINT
kevinAlbs Nov 7, 2021
2e3a815
update CONTRIBUTING with all mock server scripts
kevinAlbs Nov 7, 2021
4233f64
remove scaffolding
kevinAlbs Nov 7, 2021
3bd6ece
reject TODOs
kevinAlbs Nov 7, 2021
e62a000
remove "tls" from opts_set_kms_providers RST docs
kevinAlbs Nov 7, 2021
290f8bb
update docs on _parse_all_tls_opts and _parse_one_tls_opts
kevinAlbs Nov 7, 2021
3d489ff
clang-format CSFLE changes
kevinAlbs Nov 7, 2021
5360817
revert unnecessary BUILD_VERSION
kevinAlbs Nov 8, 2021
ac81b49
MONGOC_TEST_KMIP_* => MONGOC_TEST_CSFLE_*
kevinAlbs Nov 8, 2021
f769f20
add newline
kevinAlbs Nov 8, 2021
a37ec6b
fix formatting
kevinAlbs Nov 8, 2021
b1f3c72
refactor while loop to continue instead of 'else if'
kevinAlbs Nov 8, 2021
0a1a437
improve tmp_bson error
kevinAlbs Nov 8, 2021
fa49c41
fix variable name for env var
kevinAlbs Nov 8, 2021
e356dbd
fix format
kevinAlbs Nov 8, 2021
7638cb5
zero out error for clearer assertions
kevinAlbs Nov 8, 2021
aedec87
remove extra ca_file argument to tmp_bson
kevinAlbs Nov 8, 2021
f4fe1da
no TLS => no client cert
kevinAlbs Nov 8, 2021
5f532ce
use mongocrypt_errno
kevinAlbs Nov 8, 2021
ee5e7d6
clear errors for test assertions
kevinAlbs Nov 8, 2021
59714ef
clang-format
kevinAlbs Nov 9, 2021
f9e753d
Apply suggestions from code review
kevinAlbs Nov 12, 2021
02c74e0
Update src/libmongoc/tests/test-mongoc-client-side-encryption.c
kevinAlbs Nov 12, 2021
9eed051
update error message for insecure TLS options
kevinAlbs Nov 11, 2021
0901446
remove unnecessary else-ifs
kevinAlbs Nov 12, 2021
ebdd3dc
doc fixups
kevinAlbs Nov 12, 2021
ac9ca20
remove unused args in example
kevinAlbs Nov 12, 2021
c4699f0
Reject duplicate fields in _parse_all_tls_opts. Always leave out_opt …
kevinAlbs Nov 12, 2021
571472f
Test the assumption that it is safe to call _mongoc_ssl_opts_cleanup …
kevinAlbs Nov 12, 2021
eba179d
remove kmip arg from _make_tls_opts
kevinAlbs Nov 12, 2021
0ee3375
add test_framework_getenv_required
kevinAlbs Nov 12, 2021
e96bced
add all CSFLE env vars to test_framework_skip_if_no_client_side_encry…
kevinAlbs Nov 12, 2021
eb7c833
use test_framework_getenv_required
kevinAlbs Nov 12, 2021
6d0a1c4
extract encrypt/decrypt from custom endpoint test into separate macro
kevinAlbs Nov 12, 2021
ad8a9eb
Update src/libmongoc/tests/test-libmongoc.c
kevinAlbs Nov 12, 2021
4ea4342
Update src/libmongoc/tests/test-libmongoc.c
kevinAlbs Nov 12, 2021
faa6666
add _bson_copy_or_null
kevinAlbs Nov 12, 2021
6c769e8
fix test using uninitialized tls_opts
kevinAlbs Nov 13, 2021
16197c4
Merge branch 'master' into kmip.DRIVERS-1353
kevinAlbs Nov 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ functions:
export MONGOC_TEST_AZURE_CLIENT_SECRET="${client_side_encryption_azure_client_secret}"
export MONGOC_TEST_GCP_EMAIL="${client_side_encryption_gcp_email}"
export MONGOC_TEST_GCP_PRIVATEKEY="${client_side_encryption_gcp_privatekey}"
export MONGOC_TEST_CSFLE_TLS_CA_FILE=../drivers-evergreen-tools/.evergreen/x509gen/ca.pem
export MONGOC_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE=../drivers-evergreen-tools/.evergreen/x509gen/client.pem
fi
export LOADBALANCED=${LOADBALANCED}
export SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI}"
Expand Down Expand Up @@ -781,6 +783,8 @@ functions:
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 7999 &
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 8000 &
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 8001 &
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 8002 --require_client_cert &
python -u kms_kmip_server.py &
echo "Starting mock KMS servers... done."
start load balancer:
- command: shell.exec
Expand Down
2 changes: 2 additions & 0 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ if [ "$CLIENT_SIDE_ENCRYPTION" = "on" ]; then
wait_for_kms_server 7999
wait_for_kms_server 8000
wait_for_kms_server 8001
wait_for_kms_server 8002
wait_for_kms_server 5698
echo "Waiting for mock KMS servers to start... done."
fi

Expand Down
28 changes: 20 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,26 @@ start mongocryptd on port 27020 and set the following:

* `MONGOC_TEST_MONGOCRYPTD_BYPASS_SPAWN=on`

KMS TLS tests for Client-Side Field Level Encryption require mock KMS servers to be running in the background according to the instructions given in the Client Side Encryption Tests specification.
The set of mock KMS servers running in the background and their corresponding port number, CA file, and cert file must be as follows:

| Port | CA File | Cert File |
| --- | --- | --- |
| 7999 | ca.pem | server.pem |
| 8000 | ca.pem | expired.pem |
| 8001 | ca.pem | wrong-host.pem |
KMS TLS tests for Client-Side Field Level Encryption require mock KMS servers to be running in the background.

The [Setup instructions](https://github.com/mongodb/specifications/tree/master/source/client-side-encryption/tests#setup-3) given in the Client Side Encryption Tests specification provide additional information.

The mock server scripts are located in the [mongodb-labs/drivers-evergreen-tools](https://github.com/mongodb-labs/drivers-evergreen-tools) in the [csfle directory](https://github.com/mongodb-labs/drivers-evergreen-tools/tree/master/.evergreen/csfle). The mock servers use certificates located in the [x509gen](https://github.com/mongodb-labs/drivers-evergreen-tools/tree/master/.evergreen/x509gen) directory.

The set of mock KMS servers running in the background and their corresponding invocation command must be as follows:

| Port | CA File | Cert File | Command |
| --- | --- | --- | --- |
| 7999 | ca.pem | server.pem | python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 7999
| 8000 | ca.pem | expired.pem | python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 8000
| 8001 | ca.pem | wrong-host.pem | python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 8001
| 8002 | ca.pem | server.pem | python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 8002 --require_client_cert
| 5698 | ca.pem | server.pem | python -u kms_kmip_server.py

The path to `ca.pem` and `client.pem` must be passed through the following environment variables:

* `MONGOC_TEST_CSFLE_TLS_CA_FILE=<string>`
* `MONGOC_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE=<string>`

KMS TLS tests for Client-Side Field Level Encryption can be skipped by defining:

Expand Down
5 changes: 5 additions & 0 deletions build/evergreen_config_lib/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@

export MONGOC_TEST_GCP_EMAIL="${client_side_encryption_gcp_email}"
export MONGOC_TEST_GCP_PRIVATEKEY="${client_side_encryption_gcp_privatekey}"

export MONGOC_TEST_CSFLE_TLS_CA_FILE=../drivers-evergreen-tools/.evergreen/x509gen/ca.pem
export MONGOC_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE=../drivers-evergreen-tools/.evergreen/x509gen/client.pem
fi
export LOADBALANCED=${LOADBALANCED}
export SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI}"
Expand Down Expand Up @@ -564,6 +567,8 @@
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 7999 &
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 8000 &
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 8001 &
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 8002 --require_client_cert &
python -u kms_kmip_server.py &
echo "Starting mock KMS servers... done."
''', test=False, background=True),
)),
Expand Down
1 change: 1 addition & 0 deletions src/libmongoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ if (MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION)
mongoc_add_example (client-side-encryption-server-schema TRUE ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-server-schema.c ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-helpers.c)
mongoc_add_example (client-side-encryption-explicit TRUE ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-explicit.c ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-helpers.c)
mongoc_add_example (client-side-encryption-auto-decryption TRUE ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-auto-decryption.c ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-helpers.c)
mongoc_add_example (client-side-encryption-doc-snippets TRUE ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-doc-snippets.c)
endif ()

file (COPY ${PROJECT_SOURCE_DIR}/tests/binary DESTINATION ${PROJECT_BINARY_DIR}/tests)
Expand Down
2 changes: 1 addition & 1 deletion src/libmongoc/doc/includes/tls-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* - MONGOC_URI_TLSCERTIFICATEKEYFILE
- tlscertificatekeyfile
- Path to PEM formatted Private Key, with its Public Certificate concatenated at the end.
* - MONGOC_URI_TLSCERTIFICATEKEYPASSWORD
* - MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD
- tlscertificatekeypassword
- The password, if any, to use to unlock encrypted Private Key.
* - MONGOC_URI_TLSCAFILE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,52 @@ Parameters
* ``opts``: The :symbol:`mongoc_auto_encryption_opts_t`
* ``kms_providers``: A :symbol:`bson_t` containing configuration for an external Key Management Service (KMS).

``kms_providers`` is a BSON document containing configuration for each KMS provider. Currently ``aws`` or ``local`` are supported. At least one must be specified.
``kms_providers`` is a BSON document containing configuration for each KMS provider. Currently ``aws``, ``local``, ``azure``, ``gcp``, and ``kmip`` are supported. At least one must be specified.

The format for "aws" is as follows:

.. code-block:: javascript

aws: {
accessKeyId: <string>,
secretAccessKey: <string>
accessKeyId: String,
secretAccessKey: String
}

The format for "local" is as follows:

.. code-block:: javascript

local: {
key: <96 byte BSON binary of subtype 0> // The master key used to encrypt/decrypt data keys.
key: <96 byte BSON binary of subtype 0> or String /* The master key used to encrypt/decrypt data keys. May be passed as a base64 encoded string. */
}

The format for "azure" is as follows:

.. code-block:: javascript

azure: {
tenantId: String,
clientId: String,
clientSecret: String,
identityPlatformEndpoint: Optional<String> /* Defaults to login.microsoftonline.com */
}

The format for "gcp" is as follows:

.. code-block:: javascript

gcp: {
email: String,
privateKey: byte[] or String, /* May be passed as a base64 encoded string. */
endpoint: Optional<String> /* Defaults to oauth2.googleapis.com */
}

The format for "kmip" is as follows:

.. code-block:: javascript

kmip: {
endpoint: String
}

.. seealso::
Expand Down
55 changes: 55 additions & 0 deletions src/libmongoc/doc/mongoc_auto_encryption_opts_set_tls_opts.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
:man_page: mongoc_auto_encryption_opts_set_tls_opts

mongoc_auto_encryption_opts_set_tls_opts()
==========================================

Synopsis
--------

.. code-block:: c

void
mongoc_auto_encryption_opts_set_tls_opts (
mongoc_auto_encryption_opts_t *opts, const bson_t *tls_opts);


Parameters
----------

* ``opts``: The :symbol:`mongoc_auto_encryption_opts_t`
* ``tls_opts``: A :symbol:`bson_t` mapping a Key Management Service (KMS) provider name to a BSON document with TLS options.

``tls_opts`` is a BSON document of the following form:

.. code-block:: javascript

<KMS provider name>: {
tlsCaFile: Optional<String>
tlsCertificateKeyFile: Optional<String>
tlsCertificateKeyFilePassword: Optional<String>
}

The KMS providers ``aws``, ``azure``, ``gcp``, and ``kmip`` are supported as keys in the ``tls_opts`` document.

``tls_opts`` maps the KMS provider name to a BSON document for TLS options.

The BSON document for TLS options may contain the following keys:

- ``MONGOC_URI_TLSCERTIFICATEKEYFILE``
- ``MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD``
- ``MONGOC_URI_TLSCAFILE``

.. literalinclude:: ../examples/client-side-encryption-doc-snippets.c
:caption: Example use
:start-after: BEGIN:mongoc_auto_encryption_opts_set_tls_opts
:end-before: END:mongoc_auto_encryption_opts_set_tls_opts
:dedent: 6

See :doc:`configuring_tls` for a description of the behavior of these options.

.. seealso::

| :symbol:`mongoc_client_enable_auto_encryption()`

| The guide for :doc:`Using Client-Side Field Level Encryption <using_client_side_encryption>`

1 change: 1 addition & 0 deletions src/libmongoc/doc/mongoc_auto_encryption_opts_t.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ Synopsis
mongoc_auto_encryption_opts_set_schema_map
mongoc_auto_encryption_opts_set_bypass_auto_encryption
mongoc_auto_encryption_opts_set_extra
mongoc_auto_encryption_opts_set_tls_opts

Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,48 @@ Parameters
Description
-----------

Setting the masterkey is required if using AWS KMS, and ``masterkey`` must have the form:
Setting the masterkey is required when creating a data key with the KMS providers: ``aws``, ``azure``, ``gcp``, and ``kmip``.

Setting the masterkey is prohibited with the KMS provider ``local``.

The format of ``masterkey`` for "aws" is as follows:

.. code-block:: javascript

{
region: <string>, // Required.
key: <string>, // Required. The Amazon Resource Name (ARN) to the AWS customer master key (CMK).
endpoint: <string> // Optional. An alternate host identifier to send KMS requests to. May include port number.
region: String,
key: String, /* The Amazon Resource Name (ARN) to the AWS customer master key (CMK). */
endpoint: Optional<String> /* An alternate host identifier to send KMS requests to. May include port number. Defaults to "kms.<region>.amazonaws.com" */
}

The value of "endpoint" is a host name with optional port number separated by a colon. E.g. "kms.us-east-1.amazonaws.com" or "kms.us-east-1.amazonaws.com:443"
The format of ``masterkey`` for "azure" is as follows:

This function is only applicable for the "aws" KMS provider. It is not applicable for creating data keys with the "local" KMS provider (as configured in :symbol:`mongoc_client_encryption_opts_set_kms_providers()`).
.. code-block:: javascript

{
keyVaultEndpoint: String, /* Host with optional port. Example: "example.vault.azure.net". */
keyName: String,
keyVersion: Optional<String> /* A specific version of the named key, defaults to using the key's primary version. */
}

The format of ``masterkey`` for "gcp" is as follows:

.. code-block:: javascript

{
projectId: String,
location: String,
keyRing: String,
keyName: String,
keyVersion: Optional<String>, /* A specific version of the named key, defaults to using the key's primary version. */
endpoint: Optional<String> /* Host with optional port. Defaults to "cloudkms.googleapis.com". */
}

The format of ``masterkey`` for "kmip" is as follows:

.. code-block:: javascript

{
keyId: Optional<String>,
endpoint: Optional<String> /* Host with optional port. */
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,52 @@ Parameters
* ``opts``: The :symbol:`mongoc_client_encryption_opts_t`
* ``kms_providers``: A :symbol:`bson_t` containing configuration for an external Key Management Service (KMS).

``kms_providers`` is a BSON document containing configuration for each KMS provider. Currently ``aws`` or ``local`` are supported. At least one must be specified.
``kms_providers`` is a BSON document containing configuration for each KMS provider. Currently ``aws``, ``local``, ``azure``, ``gcp``, and ``kmip`` are supported. At least one must be specified.

The format for "aws" is as follows:

.. code-block:: javascript

aws: {
accessKeyId: <string>,
secretAccessKey: <string>
accessKeyId: String,
secretAccessKey: String
}

The format for "local" is as follows:

.. code-block:: javascript

local: {
key: <96 byte BSON binary of subtype 0> // The master key used to encrypt/decrypt data keys.
key: <96 byte BSON binary of subtype 0> or String /* The master key used to encrypt/decrypt data keys. May be passed as a base64 encoded string. */
}

The format for "azure" is as follows:

.. code-block:: javascript

azure: {
tenantId: String,
clientId: String,
clientSecret: String,
identityPlatformEndpoint: Optional<String> /* Defaults to login.microsoftonline.com */
}

The format for "gcp" is as follows:

.. code-block:: javascript

gcp: {
email: String,
privateKey: byte[] or String, /* May be passed as a base64 encoded string. */
endpoint: Optional<String> /* Defaults to oauth2.googleapis.com */
}

The format for "kmip" is as follows:

.. code-block:: javascript

kmip: {
endpoint: String
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
:man_page: mongoc_client_encryption_opts_set_tls_opts

mongoc_client_encryption_opts_set_tls_opts()
============================================

Synopsis
--------

.. code-block:: c

void
mongoc_client_encryption_opts_set_tls_opts (
mongoc_client_encryption_opts_t *opts, const bson_t *tls_opts);


Parameters
----------

* ``opts``: The :symbol:`mongoc_client_encryption_opts_t`
* ``tls_opts``: A :symbol:`bson_t` mapping a Key Management Service (KMS) provider name to a BSON document with TLS options.

``tls_opts`` is a BSON document of the following form:

.. code-block:: javascript

<KMS provider name>: {
tlsCaFile: Optional<String>
tlsCertificateKeyFile: Optional<String>
tlsCertificateKeyFilePassword: Optional<String>
}

The KMS providers ``aws``, ``azure``, ``gcp``, and ``kmip`` are supported as keys in the ``tls_opts`` document.

``tls_opts`` maps the KMS provider name to a BSON document for TLS options.

The BSON document for TLS options may contain the following keys:

- ``MONGOC_URI_TLSCERTIFICATEKEYFILE``
- ``MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD``
- ``MONGOC_URI_TLSCAFILE``

.. literalinclude:: ../examples/client-side-encryption-doc-snippets.c
:caption: Example use
:start-after: BEGIN:mongoc_client_encryption_opts_set_tls_opts
:end-before: END:mongoc_client_encryption_opts_set_tls_opts
:dedent: 6

See :doc:`configuring_tls` for a description of the behavior of these options.

.. seealso::

| The guide for :doc:`Using Client-Side Field Level Encryption <using_client_side_encryption>`

1 change: 1 addition & 0 deletions src/libmongoc/doc/mongoc_client_encryption_opts_t.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Used to set options for :symbol:`mongoc_client_encryption_new()`.
mongoc_client_encryption_opts_set_keyvault_client
mongoc_client_encryption_opts_set_keyvault_namespace
mongoc_client_encryption_opts_set_kms_providers
mongoc_client_encryption_opts_set_tls_opts

.. seealso::

Expand Down
Loading