Handling Multiple KMS Providers in a .NET Application with MongoDB
We have an application in .NET that accesses our MongoDB database and saves documents in common collections. Each user will have their own KMS Provider and respective credentials.
Problem Statement
Our initial approach was to maintain a dictionary of connections to our database, each configured with the respective KMS provider. However, an issue arises when a user wants to change their KMS provider.
Issues Encountered:
-
Rewrapping DEKs
We attempted to userewrapManyDataKey()
, but this requires the MongoDB client to have both KMS providers pre-configured. -
Manual Rewrapping of DEKs
Even when manually rewrapping the Data Encryption Keys (DEKs) in our code, documents inserted using the previous KMS Provider become inaccessible because:- The collection’s encryption schema is still tied to the previous KMS provider.
- The new connection has problems recognizing the KeyVault collection.
Question
Is this a misunderstanding on our part, or is it a real limitation of MongoDB?
Is there a way to seamlessly change the KMS provider for an existing Queryable Encryption collection?