Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-4889

Support Linux distros using libdl.so.2

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.27.0
    • Affects Version/s: None
    • Component/s: None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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

            Assignee:
            adelin.mbidaowona@mongodb.com Adelin Mbida Owona
            Reporter:
            eric_rosenquist@cysiv.com Eric Rosenquist
            Votes:
            1 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: