Wednesday, April 22, 2015

While Restoring the DB - Sql Exception: Cannot Find Server Certificate with Thumbprint

To resolve the issue complete the following steps:
  1. Connect to SQL instance on the Agent machine via SQL Sever Management Studio.
  2. Find the encrypted database and click through the context menu All tasks -> Encryption. You will see a certificate name.
  3. Select master database and execute the following query to export the certificate:
    1. BACKUP CERTIFICATE cert_name TO FILE=’C:\1.certbak’
    2. WITH PRIVATE KEY (
    3. FILE=’C:\1.pkbak’,
    4. ENCRYPTION BY PASSWORD=’ENTER ANY PASSWORD HERE’)
    5. NOTE: cert_name – is the name of the certificate.
  4. Copy C:\1.pkbak and  C:\1.certbak from the Agent to the Core machine.
  5. On the Core machine, connect to Core SQL instance via SQL manager and execute the following query to import the certificate:
    1. REATE CERTIFICATE certificate_name
    2. FROM FILE=’C:\1.certbak’
    3. WITH PRIVATE KEY(
    4. FILE=’C:\1.pkbak’,
    5. DECRYPTION BY PASSWORD=’ENTER ANY PASSWORD HERE’)
    6. NOTE: certificate_name – this name should be unique.
  6. In some cases SQL instance will ask you to create master key. To do this execute the following query:
    1. CREATE MASTER KEY
    2. ENCRYPTION BY PASSWORD = ’123′
  7. Then perform query from step 4 once again.
    1. NOTE: Certificate with Unique Thumbrint should be imported only one time.
  8. Perform these steps for every certificate in use on the Agent machine.
  9. Perform attachability check to verify that the issue has been resolved.
  10. Delete the files *.pkbak and  *.certbak from C drive of the Agent machine.

No comments:

Time Machine