Query Encrypted Data from MongoShell - Community Edition

Hello,

We’re using MongoDB Community Edition 4.4.16. We are using MongoDB as our Database in our current project and wanted to implement Client Side Field Level Encryption. We’ve implemented and tested Explicit Encryption and Automatic Decryption with Python as our’s is community Edition. Everything is fine except that we’re unable to find a way to query the encrypted data from Mongo Shell. Since we require CSFLE ClientEncryption Instance to query, we can’t seem to find a way to import Master Key into Shell as Mongo only accepts .js files.

We’ve created 96 byte character master key using openssl.

openssl rand 96 > master-key.txt

Can someone please suggest how to proceed with this? We want to query the encrypted fields from Mongo Shell.

Hi @Bhargav_Sai ,

I suggest to review the example in this article:

In this example the key is pasted as a whole into a “key” variable maybe you can do the same or pipe it to the shell

Thanks
Pavel

Thank you. I am able to retrieve the key using keyAltName method.

1 Like