Hi,
I’m trying to perform automatic client-side field level encryption using mongoDB Enterprise Server 4.2 (ultimately Mongo Atlas 4.2 Cluster) and Node mongo driver version 3.6.1.
I’ve already tested connections and installations by performing the same routine using both servers associated with a compatible mongo shell script.
When using the node driver, I see that the mongocryptd starts but the encryption doesn’t actually occur.
I have two different behaviours depending on how I use the schema. When I JSON.stringify it before inserting a document, the insertion results in success but no encryption is performed and the data is saved as plain text.
If I initialise the client with the JS object for the schema, I get the following error: MongoError: Array elements must have type BinData, found object
I’ve even tried starting the mongocryptd process manually on port 27020 and only then run the script. I see that connections are made to mongocryptd but still no data is encrypted.
Just based on the information that you’ve provided, it seems like there was a slight error in how the script encrypts. You may find the examples listed on Client Side Field Level Encryption Guide useful as a reference (You can toggle the code snippets to Node.JS).
If you are still encountering the issue, please provide an example code that could reproduce the error.
Not sure I understood what you meant, but I’ve already used that resource to get to where I am now.
Even if I try copying all the code there, just changing the kms and the server, I still get the same behaviour.
Assuming I have correct master key on KMS and data encryption key (since it worked for mongo shell), this is the code I’m using: