ExportXMLWordPrintableJSON

    • None
    • Dotnet Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      On Windows, auto-encryption can't load the crypt_shared library if the path given in cryptSharedLibPath contains any non-ASCII character, for example C:\Users\Zoë\app\mongo_crypt_v1.dll or a folder with a Cyrillic or Chinese name. Linux and macOS are not affected.

      The driver passes the path to libmongocrypt with [MarshalAs(UnmanagedType.LPStr)] (src/MongoDB.Driver.Encryption/Library.cs, mongocrypt_setopt_set_crypt_shared_lib_path_override and mongocrypt_setopt_append_crypt_shared_lib_search_path). On Windows, LPStr converts the string through the system ANSI code page. libmongocrypt expects UTF-8, so the path it receives doesn't match the real file.

      Affects 3.0.0 – 3.12.0 and current main. 2.x used the separate MongoDB.Libmongocrypt package and was not checked.

      Observed (Windows Server 2022, code page 1252, crypt_shared 8.0.32, cryptSharedLibRequired = true):

      Folder containing mongo_crypt_v1.dll Result
      C:\test\cspath\cs_ascii loads
      ...\cs_données CryptException: CryptSharedLib is required, but was not found or not loaded.
      ...\cs_база same error

      When cryptSharedLibRequired isn't set (the default is false), there's no error. The driver silently falls back to spawning mongocryptd, so the app ends up depending on a separately installed mongocryptd process without knowing it.

      Expected: crypt_shared loads from any valid path, as it does on Linux and macOS.

      Suggested fix: marshal both path parameters as UTF-8 ([MarshalAs(UnmanagedType.LPUTF8Str)]). With that change, all three folders above load (verified on net10.0). Still to check: that LPUTF8Str behaves the same on net472 for these delegate-based calls.

            Assignee:
            Unassigned
            Reporter:
            Adelin Mbida Owona
            None
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: