Thursday, September 29, 2011

CAPICOM: Keyset does not exist

Recently I have been trying to port a classic ASP application to ASP.Net. The major thing to do was to keep using CAPICOM for encryption. The reason was that the data we encrypt goes to a 3rd party vendor who decrypts them using CAPICOM and they were not going to change their side of the program.

Two specific problems that I encountered whenever deploying my application to servers.
a.) Retrieving the COM class factory for component with CLSID {94AFFFCC-6C05-4814-B123-A941105AA77F} failed due to the following error: 80040154
This I could resolve by registering the CAPICOM dll on the server (regsvr32). I was assuming that this would not be necessary given that I have a .Net wrapper around the CAPICOM dll (using tlbimp. MSDN).

b.) Keyset does not exist
Searching on Bing/Google led me to several sites saying it's permission issue on the Machine Keys folder. I tried setting permission for all users I could think of: ASPNet, IUSR, IWAM, Service Account. But this did not help. Then I imported the certificate from the old machine where classic ASP application is running and voila! the encryption algorithm started working. I removed all permission settings for the ASP.Net users mentioned before and it still worked.
I am not sure why this is!

No comments: