I have two instances, InstanceA running under accountA, and InstanceB running under accountB.
Both instances are on the same machine.
I have a cert on InstanceA. It and its Private key are backed up:
BACKUP CERTIFICATE MyServerCert TO FILE = 'C:\SQLServerFiles\myServerCert.cer'
WITH PRIVATE KEY ( FILE = 'C:\SQLServerFiles\privateKey.pvk' ,
ENCRYPTION BY PASSWORD = 'Password1' );
I now try to restore this to InstanceB. I create a database master key and then run code to restore the cert:
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'Password1';
--this runs successfully
CREATE CERTIFICATE MyServerCert
FROM FILE = 'C:\SQLServerFiles\myserverCert.cer'
WITH PRIVATE KEY
FILE = 'C:\SQLServerFiles\privatekey.pvk'
,DECRYPTION BY PASSWORD = 'Password1'
I now get the error:
Msg 15208, Level 16, State 1, Line 1
The certificate, asymmetric key, or private key file does not exist or has invalid format.
If i change the service account of InstanceB to accountA, i dont get any issues. Can anyone explain why this is?
Update: I granted accountB admin rights on the server ( its only a local dev machine) but this still did not help, although it rules out any question of if the account has access to the directory that contains the cert and private key