Encryption does not work in container that works in Mac m1

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • 5
    • Not Needed
    • 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?
    • None
    • None
    • None
    • None
    • None
    • None

      In short when running in container on Apple Silicon I receive this error:

       

      ```

      2023-09-28 09:28:49 /app/node_modules/mongodb/src/encrypter.ts:124
      2023-09-28 09:28:49       throw new MongoMissingDependencyError(
      2023-09-28 09:28:49             ^
      2023-09-28 09:28:49 MongoMissingDependencyError: Auto-encryption requested, but the module is not installed. Please add `mongodb-client-encryption` as a dependency of your project
      2023-09-28 09:28:49     at Function.checkForMongoCrypt (/app/node_modules/mongodb/src/encrypter.ts:124:13)
      2023-09-28 09:28:49     at parseOptions (/app/node_modules/mongodb/src/connection_string.ts:443:15)
      2023-09-28 09:28:49     at new MongoClient (/app/node_modules/mongodb/src/mongo_client.ts:331:34)
      ```

      This error message is deceptive because, of course dependency is there and when I run without container there is no error

      extract from package.json

      ```

          "mongodb-client-encryption": "^6.0.0",

      ```

      The container itself builds from 
      FROM arm64v8/node:19.9 (which I believe is an ubuntu image)

      The difference is in the library that is used

      we have the library being chosen dynamally depending on the platform like this:

      ```

        private getAutoEncryptionOptions() {
          const autoEncryptionOptions = {
            keyVaultNamespace: `${this.dbName}.${MONGODB_KEY_VAULT_COLLECTION}`,
            kmsProviders: this.kmsProviders,
            extraOptions:

      {         cryptSharedLibPath: MONGODB_SHARED_LIB_PATH,       }

      ,
          };

          return autoEncryptionOptions;
        }

      export const MONGODB_SHARED_LIB_PATH =
        process.platform === 'win32'
          ? 'libs/mongo_crypt_v1.dll'
          : process.platform === 'darwin'
          ? 'libs/mongo_crypt_v1.dylib'
          : 'libs/mongo_crypt_v1.so';
      ```

      So when I run directly on mac m1 it picks  mongo_crypt_v1.dylib and all runs smoothly. However when I run in container it probably tries to pick mongo_crypt_v1.so. Unfortunatelly, I don't see the exact error - it's just my guess because as I mentioned above the error message is deceptive. 

      Not being able to use docker on m1 because of encryption is major hurdle. I would like to know whether you may suggest any workaround. How to link the correct library? How to build the correct library in docker from scratch?

            Assignee:
            Warren James (Inactive)
            Reporter:
            Nikolay Zakirov
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: