Keyset does not exist error in .NET application

Keyset does not exist error in .NET application

When using WCF to communicate with a web service that required a client certificate, I couldn’t get the solution to run unless I started Visual Studio as an administrator.
The error that I got was :

Keyset does not exist

I knew full well the private key did exist (you can see this in MMC > Certificates). So it had to be a security related issue, seeing that when I run it as admin I have no issues.

After some google’ing, I came across this post: stackoverflow – winhttpcertcfg.

It describes how you can use a little programme to find the private key file. More information about the FindPrivateKey tool can be found here.

Note: This tool requires visual studio to compile the sourcecode.

Download the WCF and WF samples for the .NET 4 framework.

Go to WCF > Setup > FindPrivateKey folder

Compile solution and navigate to the bin folder

Start a CMD (with admin rights) and navigate to this bin folder

D:\WF_WCF_Samples\WCF\Setup\FindPrivateKey\CS\bin>FindPrivateKey.exe My LocalMachine -t "enter certificate thumbprint here"

The above command will search the Personal store in the local machine for a certificate with the given thumbprint.

Private key directory:
Private key file name:

Now navigate to this directory and set the appropriate access rights to this file.
Thats it. Run your WCF project as a normal user and it should work now.

One thought on “Keyset does not exist error in .NET application

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.