Wednesday, August 7, 2013

ERROR - Keyset does not exist - When a web site hosted in IIS, have a certificate installed in server.


[FaultException`1: Keyset does not exist
]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9442991
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +345


I was accessing a WCF web service from a web application hosted in IIS. The call to the external web service is validated with a certificate installed in server. This certificate should match with the certificate in the third party side. After successful validation, we get the output.

But I was getting error as mentioned above. It was something related to the certificate. Finally I found out that the account with which my web application runs doesn't have access to the certificate. So I had to add the user account  "Network Service" full rights to the certificate. It is done as below:

1. Type mmc(Microsoft Management Console) from run.
2. Click on File --> Add/Remove Snaps-ins
3. Select Certificates from Available snap-ins and Add to Selected snap-ins.
4. Use Computer account from next prompt.
5. Click Next and select Local Computer and click Finish, now the certificate is added in selected snap-ins list, click OK.
6. Click certificates and find your certificate and right click --> All tasks --> Manage Private Keys
7. Add "NETWORK SERVICE" account with Full control. Click OK.

After this you will be able to access the third party web service from your web app hosted in IIS.

Basically the account with which your web app runs needs to have access to the certificate. This worked for me like a charm.

Hope this helps somebody without wasting much time trying to figure out, where does the error come from.


No comments:

Post a Comment