Encrypting a collection with CSFLE

I am using the Java driver.

I have successfully set up my KMS key store to store my master key.

I am using it to create DEK’s in our MongoDB key store on our cluster.

I have successfully encrypted/decrypted FIELDS using the DEKS.

I have seen and read in several presentations that encryption can be applied to a COLLECTION and DOCUMENT, but NONE of the documentation or example show how to accomplish this. All of them define how to encrypt individual field defined in the jsonschema.

So is there a way to configure Enterprise encryption to encrypt documents written too/read from a collection or entire documents without having to explicitly defined the field names in the jasonschema ?

If so i would LOVE to pointed in the direction of samples/examples. I reviewed and implemented the code from the Auto Encryption Settings tour, but it does NOT actually encrypt the data. Just writes the data in plain text.


Hi @Paul_Calhoun, and welcome to the forum

There are quite a few things to clarify here. First, would you be able elaborate further what you’re trying to achieve? i.e. background context, or use case.

Client-Side Field Level Encryption (CSFLE) as the name suggests, it encrypts at the field level. In order to encrypt an entire document, you must encrypt each individual field in the document.

Would you be able to point out which presentations mentioned the encryption on the whole collection/document ?

If you have defined a field to be encrypted and in the database you could see the document field containing a plain text data, that is not the expected behaviour from CSFLE. Please see CSFLE Guide for a tutorial. The guide contains an example utilising MongoDB Java driver (sync). See also github.com/mongodb-university/csfle-guides for an example project repository.