Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5663

Encryption does not work in container that works in Mac m1

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • 5
    • Not Needed
    • 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?

    Description

      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?

      Attachments

        Activity

          People

            warren.james@mongodb.com Warren James
            nikolay.zakirov@terminal3.io Nikolay Zakirov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: