?
Solved

Master Key Encryption and Certificate Encryption Errors

Posted on 2009-04-22
1
Medium Priority
?
778 Views
Last Modified: 2012-05-06
I'm trying to create an encryption certificate using my  Master Key.   But first I'm trying to recreate the encryption because I am on a new db server.   I backed up and restored all my DB's to this new server.  normally to recreate the encryption all i would do is run this command:


OPEN MASTER KEY DECRYPTION BY PASSWORD = 'foobar'
ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY

However, this is giving me the error:

Msg 15466, Level 16, State 2, Line 3
An error occurred during decryption.

When i try to create a certificate using this command but not running the above command:

CREATE CERTIFICATE PMRCertificate  WITH SUBJECT ='This is PMRs Cert'

I get this error:
Please create a master key in the database or open the master key in the session before performing this operation

However, if i run the second comman immediately after the first (even though the first gives me the error:  An error occurred during decryption.) then i am able to create the cert.  I can even encrypt using that cert into a varbinary(128) field.  however, when i go to decrypt it comes back NULL.  

So, what the heck am i doing wrong and what do i need to do to fix this whole mess.  I really don't want to resort to doing the encryption via a hardcoded password (ie EncryptByPassword)


0
Comment
Question by:davidcahan
1 Comment
 
LVL 31

Accepted Solution

by:
RiteshShah earned 2000 total points
ID: 24212898
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question