CSFLE with the .NET driver doesn't work on Linux distros such as Debian 11 due to a dependency on libdl.so for loading the libmongocrypt.so library. On Debian 11 (and several other distros), the dlopen and dlsym functions reside in libdl.so.2. The dependency is in the LinuxLibrary class in bindings/cs/MongoDB.Libmongocrypt/LibraryLoader.cs
At runtime, the library throws an exception such as:
System.DllNotFoundException: Unable to load shared library 'libdl' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl: cannot open shared object file: No such file or directory at MongoDB.Libmongocrypt.LibraryLoader.LinuxLibrary.dlopen(String filename, Int32 flags) at MongoDB.Libmongocrypt.LibraryLoader.LinuxLibrary..ctor(String path) at MongoDB.Libmongocrypt.LibraryLoader..ctor() at MongoDB.Libmongocrypt.Library.<>c.<.cctor>b__0_65() at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy`1.CreateValue() at System.Lazy`1.get_Value() at MongoDB.Libmongocrypt.Library.<>c.<.cctor>b__0_1() at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy`1.CreateValue() at MongoDB.Libmongocrypt.CryptClientFactory.Create(CryptOptions options) at MongoDB.Driver.Core.Clusters.CryptClientCreator.CreateCryptClient(CryptOptions options) at MongoDB.Driver.Core.Clusters.CryptClientCreator.CreateCryptClient(CryptClientSettings cryptClientSettings) at MongoDB.Driver.Encryption.ClientEncryption..ctor(ClientEncryptionOptions clientEncryptionOptions)
The NativeLibrary class might help, but can't be used since libmongocrypt targets .NET Standard and that library is not available on .NET Standard.
The https://github.com/mellinoe/nativelibraryloader package might be a viable alternative since it supports .NET Standard 2.0 and supports systems that use libdl.so as well as ones that use libdl.so.2
- is related to
-
CSHARP-4363 Investigate csfle assembly loading failures in .net 6 and alpine env
- Closed
- related to
-
SERVER-49140 [FLE] Add mongocryptd for Linux Alpine
- Closed