Sql-server – Does AE certificate include both master and encryption keys together

always-encryptedencryptionsql server

After setting up Always Encrypted, I can see a certificate in my Current User
enter image description here

when selecting

select * from sys.column_master_keys

under the key_path I see this location, but there is no location specified for encryption keys. So is just this certificate export enough? Does it contain both master and encryption keys together in the same certificate?

Thanks

Best Answer

After setting up Always Encrypted, I can see a certificate in my Current User

Correct, you've stated that the Column Master Key (CMK) will be created/stored there. Most likely this was done via the GUI to generate a new key and save it there. There are other options as well for the CMK.

[...] under the key_path I see this location, but there is no location specified for encryption keys.

Correct, that was the location used when executing the metadata update to SQL Server for where the CMK exists. Since SQL Server doesn't go out and touch that Certificate (which shouldn't be in the server) it only knows what to send back to the client driver as metadata. The certificate holds an asymmetric key pair that is used to encrypt and decrypt the Column Encryption Key (CEK) which is stored inside of SQL Server in the same database.

So is just this certificate export enough?

Assuming AE is setup correctly, the client only needs that certificate, yes. There are obviously database level permissions that are required to get said metadata but overall the process is moot if you don't have a copy of the CMK.

Does it contain both master and encryption keys together in the same certificate?

No, as I stated, there is the CMK which is the certificate you've created and then there is the CEK which does the actual encryption and decryption of the data.

You'll want to go back and read a bit more about Always Encrypted and how it works as this is all explained in the documentation.