Skip to content

Commit 09f1d51

Browse files
DRIVERS-2449 Omit mongocryptd client (#1330)
1 parent 9fec9df commit 09f1d51

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

source/client-side-encryption/client-side-encryption.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Client Side Encryption
44

55
:Status: Accepted
66
:Minimum Server Version: 4.2 (CSFLE), 6.0 (Queryable Encryption)
7+
:Last Modified: 2022-10-26
8+
:Version: 1.11.0
79

810
.. _lmc-c-api: https://github.com/mongodb/libmongocrypt/blob/master/src/mongocrypt.h.in
911

@@ -1572,6 +1574,9 @@ is propagated to the user.
15721574
Connecting to mongocryptd_
15731575
--------------------------
15741576
1577+
If the crypt_shared_ library is loaded, the driver MUST NOT attempt to connect
1578+
to mongocryptd_. (Refer: `Detecting crypt_shared Availability`_).
1579+
15751580
Single-threaded drivers MUST connect with `serverSelectionTryOnce=false <../server-selection/server-selection.rst#serverselectiontryonce>`_
15761581
, connectTimeoutMS=10000, and MUST bypass `cooldownMS <../server-discovery-and-monitoring/server-discovery-and-monitoring.rst#cooldownms>`__ when connecting to mongocryptd. See `Why are serverSelectionTryOnce and cooldownMS disabled for single-threaded drivers connecting to mongocryptd?`_.
15771582
@@ -1583,7 +1588,7 @@ selection error is propagated to the user.
15831588
.. note::
15841589
15851590
A correctly-behaving driver will never attempt to connect to mongocryptd_
1586-
when |opt-crypt_shared-required| is set to |true|.
1591+
when |opt-crypt_shared-required| is set to |true| or crypt_shared_ is loaded.
15871592
15881593
ClientEncryption
15891594
================
@@ -2515,6 +2520,7 @@ Changelog
25152520
:align: left
25162521
25172522
Date, Description
2523+
22-10-26, Do not connect to `mongocryptd` if shared library is loaded.
25182524
22-10-11, Specify a timeout on Azure IMDS HTTP requests and fix the resource URL
25192525
22-10-05, Remove spec front matter and ``versionadded`` RST macros (since spec version was removed)
25202526
22-09-26, Add behavior for automatic Azure KeyVault credentials for ``kmsProviders``.

source/client-side-encryption/tests/README.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,3 +2379,43 @@ This should successfully load and use the Azure credentials of the service accou
23792379
attached to the virtual machine.
23802380

23812381
Expect the key to be successfully created.
2382+
2383+
20. Bypass creating mongocryptd client when shared library is loaded
2384+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2385+
2386+
.. note::
2387+
2388+
IMPORTANT: If crypt_shared_ is not visible to the operating system's library
2389+
search mechanism, this test should be skipped.
2390+
2391+
2392+
The following tests that a mongocryptd client is not created when shared library is in-use.
2393+
2394+
#. Start a new thread (referred to as ``listenerThread``)
2395+
2396+
#. On ``listenerThread``, create a TcpListener on 127.0.0.1 endpoint and port 27021. Start the listener and wait for establishing connections.
2397+
If any connection is established, then signal about this to the main thread.
2398+
2399+
Drivers MAY pass a different port if they expect their testing infrastructure to be using port 27021. Pass a port that should be free.
2400+
2401+
#. Create a MongoClient configured with auto encryption (referred to as ``client_encrypted``)
2402+
2403+
Configure the required options. Use the ``local`` KMS provider as follows:
2404+
2405+
.. code:: javascript
2406+
2407+
{ "local": { "key": <base64 decoding of LOCAL_MASTERKEY> } }
2408+
2409+
Configure with the ``keyVaultNamespace`` set to ``keyvault.datakeys``.
2410+
2411+
Configure the following ``extraOptions``:
2412+
2413+
.. code:: javascript
2414+
2415+
{
2416+
"mongocryptdURI": "mongodb://localhost:27021"
2417+
}
2418+
2419+
#. Use ``client_encrypted`` to insert the document ``{"unencrypted": "test"}`` into ``db.coll``.
2420+
2421+
#. Expect no signal from ``listenerThread``.

0 commit comments

Comments
 (0)