Reputation: 73
To make an incredibly long story short, how can I return a database back to the point where it never had any master keys, certificates, etc on it?
The data that is currently encrypted is test data, therefore I don't need to keep it.
I detached the database and moved it to the future production server, but didn't do all the stuff I should have done to make it work.
Here is what I've tried and the results:
status: abandoned
status: abandoned
status: abandoned
DROP DATABASE ENCRYPTION KEY
DROP CERTIFICATE TDECertificate
DROP MASTER KEY
status: worked on home machine, able to get everything running perfectly, but that was the machine with the original set up so it was not broken in the way production is currently. Plan to try this on production tonight (I can only work on this remotely for about an hour per night)
Is there anything else I need to do to sorta return it to out of the box in terms of master keys and encryption? Do I need to regenerate the service master key as well ( I think I read that can be done)
Upvotes: 3
Views: 3319
Reputation: 216
I suspect you are asking the wrong question because the answer to "how can I return the database back to the point where is has no keys?" is to drop all of the keys. You also said you don't care about the encrypted data since it is test data. However, if your goal is to migrate the encryption from your system to the production system and it is working on your system, then you need to back up the Database Master Key to a file and restore it to the production database. The fact that you did not retain the original password used to encrypt the key in SQL Server is irrelevant because when the DMK was created, the system also encrypted it with the Service Master Key. When you backup the DMK, the system can decrypt the key for you without you providing the original password. Unless you explicitly executed a command to drop the encryption by service master key, you can backup the DMK to a file, provide a password which encrypts the file, migrate the file to your production system and restore it using the file encryption password previously provided. Or you can drop all keys and rebuild the encryption hierarchy giving the keys and certificates the same name.
Upvotes: 0