Skip to content

Commit 003b41e

Browse files
kevinAlbstimgraham
authored andcommitted
PYTHON-5677 Prevent ClientEncryption from loading crypt shared library
1 parent 6ccaae5 commit 003b41e

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

doc/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ PyMongo 4.16 brings a number of changes including:
1717
- Fixed return type annotation for ``find_one_and_*`` methods on :class:`~pymongo.asynchronous.collection.AsyncCollection`
1818
and :class:`~pymongo.synchronous.collection.Collection` to include ``None``.
1919
- Added support for NumPy 1D-arrays in :class:`bson.binary.BinaryVector`.
20+
- Prevented :class:`~pymongo.encryption.ClientEncryption` from loading the crypt
21+
shared library to fix "MongoCryptError: An existing crypt_shared library is
22+
loaded by the application" unless the linked library search path is set.
2023

2124
Changes in Version 4.15.5 (2025/XX/XX)
2225
--------------------------------------

pymongo/asynchronous/encryption.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,10 @@ def __init__(
717717
self._encryption = AsyncExplicitEncrypter(
718718
self._io_callbacks,
719719
_create_mongocrypt_options(
720-
kms_providers=kms_providers, schema_map=None, key_expiration_ms=key_expiration_ms
720+
kms_providers=kms_providers,
721+
schema_map=None,
722+
key_expiration_ms=key_expiration_ms,
723+
bypass_encryption=True, # Don't load crypt_shared
721724
),
722725
)
723726
# Use the same key vault collection as the callback.

pymongo/synchronous/encryption.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,10 @@ def __init__(
710710
self._encryption = ExplicitEncrypter(
711711
self._io_callbacks,
712712
_create_mongocrypt_options(
713-
kms_providers=kms_providers, schema_map=None, key_expiration_ms=key_expiration_ms
713+
kms_providers=kms_providers,
714+
schema_map=None,
715+
key_expiration_ms=key_expiration_ms,
716+
bypass_encryption=True, # Don't load crypt_shared
714717
),
715718
)
716719
# Use the same key vault collection as the callback.

0 commit comments

Comments
 (0)