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

Client Side Field Level Encryption (CSFLE) returns an error when using MongoDB Atlas

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.5.0
    • Component/s: Client Side Encryption
    • Labels:
    • Environment:
      - Mongoose is not currently being used, however I would hope the fix to this issue can be applied to mongoose as well

      My issue is when I try to connect to my Atlas database and have automatic encryption enabled, I get an error - 

      BSON field 'insert.jsonSchema' is an unknown field.

       

      My script to reproduce is below. Mongocryptd should be running on Atlas's side and is not running on my pc.

      const base64 = require('uuid-base64');
      const { ClientEncryption } = require('mongodb-client-encryption');
      const mongodb = require('mongodb');
       
      const User = mongoose.model('users');
      const { MongoClient, Binary } = mongodb;
      const { port, databaseUri, awsAccessID, awsAccessKey, awsRegion, cmkARN } = require('./env')
      
      run().catch(err => console.log(err));
      
      async function run() {
        constkeyVaultNamespace = 'resellanalytics.encryption';
        constkmsProviders = {
          aws: {
            accessKeyId:`${awsAccessID}`,
            secretAccessKey:`${awsAccessKey}`,
          }
        };
      
        const client = await mongoose.connect(databaseUri, {
          useNewUrlParser:true,
          useUnifiedTopology:true,
          autoEncryption: {
            keyVaultNamespace,
            kmsProviders,
            extraOptions: { mongocryptdURI:databaseUri }
          }
        });
      
        const encryption = new ClientEncryption(client.connection.client, {
          keyVaultNamespace,
          kmsProviders
        });
       
        const key = await encryption.createDataKey('aws', {
          masterKey: {
            key:cmkARN, // e.g. 'arn:aws:kms:us-east-2:111122223333:alias/test-key'
            region:awsRegion, // e.g. 'us-east-1'
          }
        });
      }
      

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            rakochh@gmail.com Rahul Kochhar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: