After moving a database from one server to another, we started having an issue:
> Msg 15581, Level 16, State 7, Procedure xxxxx, Line 24 [Batch Start Line 2]
Please create a master key in the database or open the master key in the session before performing this operation.
Msg 15315, Level 16, State 1, Procedure xxxxx, Line 62 [Batch Start Line 2]
The key '<CustomKeyName>' is not open. Please open the key before using it.
The procedure in question has:
OPEN SYMMETRIC KEY MySymKey
DECRYPTION BY CERTIFICATE MySymCert;
I can verify that after moving the DB, I can see a symmetric key
and a certificate
by querying sys.symmetric_keys
and sys.certificates
.
We, yeah, don't have the master key pass. I'm curious if this process would work:
- In the old server (in the DB scope):
ALTER MASTER KEY REGENERATE WITH ENCRYPTION BY PASSWORD = 'a_cool_pass';
backup DB again
Retore DB in the new server again (with replace)
OPEN MASTER KEY DECRYPTION BY PASSWORD = 'the_cool_Pass'
ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY
would this be a proper solution for this situation?
OR, can I just drop the symetric_key and cert, and recreate?
edit: REGENERATING
the master key pass in the old server, backup/restore into new, OPEN MASTER KEY DECRYPTION BY PASSWORD =
got the issue The key is not encrypted using the specified decryptor.
( what I thought it was strange. I will try again tomorrow.
(would I need to do a backup restore of the certificate?