Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5377

Passing a encryptedFieldsMap value to the .encryptedFieldsMap property causes startup failures when using automatic encryption

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: 5.0.0
    • Component/s: Client Side Encryption
    • None
    • Java Drivers
    • 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?

      Summary

      The AutoEncryptionSettings.builder() has support for supplying a value to the .encryptedFieldsMap property. But setting this value when you using Automatic Encryption creates an error about the keyId value. 

      Specifically setting the keyId to an instance of BsonNull() produces an error of 

       

       

      Caused by: com.mongodb.crypt.capi.MongoCryptException: expected 'fields.keyId' to be type binary, got: 10
       
      

       

      Omitting the keyId field produces this error. 

       

       
      Caused by: com.mongodb.crypt.capi.MongoCryptException: unable to find 'keyId' in 'field' document
       
      

       

      This is using 5.0.0 over the driver and associated libraries. 

      This was tested against a local copy of Enterprise Advanced 7.0 configured for a single node replica set. 

      How to Reproduce

      The full code to test this exists at this Github repo. 

      github.com:jesmith17/mongodb-sprint-zero.git. Execute the java-sample project. It can be run using the command 

       

       
      mvn spring-boot:run
       
      

       

      To create the issues simply uncomment line 174 of class MongoDBConnection.java. This will set the field on the AutomaticEncryptionSettings and create the error. 

      To produce the second error above, comment out the keyId fields in lines 139, 143, and 147

       

       

      The existence of this property .encryptedFieldsMap as part of the AutomaticEncryptionSettings object does make any sense. If there is no way to set it to valid values, and if the fieldMap is only required client side in a case of using explicit encryption. then the field should be removed to not cause confusion. 

       

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            josh.smith@mongodb.com Josh Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: