I have some confusion about Always Encrypted concept. Please follow below scenario.
I have created CMK (name - CMK_01) on Machine A under CurrentUser/My folder. By this way I have Always Encrypted certificate generated on Machine A which I have exported.
After this I have created CEK (name - CEK_01) from Machine A using this CMK (CMK_01).
After this I have created table (name - TBL_01) on Machine B and used this CEK_01 to encrypt its column (name – COL_01).
Now to test Always Encrypted concept I have installed Always Encrypted certificate on Machine B and applied Column Encryption Setting = Enabled in SSMS.
After doing this I am able to insert data with parameterized query in this table (TBL_01). I queried on this table and I found that data is in decrypted form (i.e. plain text).
After this I queried on this table from Machine C without installing certificate and I found data is in encrypted form. So basically it works perfectly from db side. This works based on certificate installed on individual machine and depends on folder in which it installed (Current or Local computer).
If Current then it works only for user which certificate is installed and if Local then works for all the users on that machine.
Now issue comes over here,
I tried to leverage this functionality to .NET side. So I have included Column Encryption Setting = Enabled in connection string of .NET code. And then I deployed .NET code on server machine (Machine D). After this I have installed always encrypted certificate on one of the user machine (Machine E) under CurrentUser/My folder.
Now when user on Machine E is trying to see the data in UI, it is giving an error. Basically encryption does not work here.
To resolve this I have created new CMK (name – CMK_01) with same certificate key but path of CMK is under LocalMachine\My.
Then I have added this new CMK value in existing CEK (CEK_01).
So now basically we have 2 CMK - same certificate key with different path and 1 CEK with 2 different CMK values which means both CMK can access this CEK.
After this we installed Always Encrypted Certificate on IIS server (under LocalMachine\My path) where our code has been deployed (Machine D). After this error has been removed but all the users who can login to that web page they can encrypt/decrypt data because we have installed certificate on IIS server (Machine D).
Now my ask is -
Is this our implementation correct?
Is this how Always Encrypted works? I mean can't we have individual user wise encryption and decryption by installing certificate on user's individual machine so who has that certificate access that user is only able to encrypt/decrypt data otherwise rest of the users who does not have that certificate those users can only see data in encrypted form on that web page?