Search code examples
mongodbencryptionmongodb-csfle

Does MongoDb 'Client Side Field Level Encryption' (CSFLE) support searching DB for a encryted field?


If I configure my MongoDb to use 'Client Side Field Level Encryption' (CSFLE), is it possible for a client to search the DB collections for a encryted field. As example - if I encrypt a property/field 'EmailAddress' of a POCO-Class-User and later want to search for that User via Searchstring of that emailAddressValue. Does the MongoDbServer autoencrypt the seachValue and looks it up? And is this encrytion 'deterministic'? Meaning will the same input always result in the same encryted output? Thx -- I use the C# Driver of MongoDb and Atlas MongoDb (4.4.10 // Free Tier).


Solution

  • Yes, see here. You will need using non empty filter in the second example:

    var result = collection.Find("{ 'encryptedField' : '123456789' }").First();
    

    the same logic will work with typed filter.