CryptoAPI cryptographic service provider (CSP) for this implementation could not be acquired during

D

Don Nelson

Hi,
We are trying to encrypt and decrypt some fields using RSA
algorithm.The class being used is RSACryptoServiceProvider.We have put
a key in its XML representation in Registry and evrytime whenever we
invoke our custom encryption class, it instantiates
RSACryptoServiceProvider class with its default constructor.Please
look at following snippet:
RSACryptoServiceProvider rsaProvider = new RSACryptoServiceProvider();

/* Creating the RSACryptoServiceProvider object from the XML string
of the Key(which is read from the registry.)
The key is inserted in the registry while environment was et up
initially. */

rsaProvider.FromXmlString(Key);

Our environment has 5 machines and all the 5 machines have this key in
their registry.This ensures that passwords encrypted on one machine
can be decrypted on other machine.That is the reason we cannot use
cspParameters class and cspFlags and hence UseMachineKeyStore
property.
The problem occurs when we run around 1000 successive requests for
encryption.After successful execution of 300-400 requests, we get an
error saying "CryptoAPI cryptographic service provider (CSP) for this
implementation could not be acquired".As much as we have read on Net,
this occurs because ASP.net is not an interactive user and hence needs
to use UseMachineKeyStore property.However we cannot use this for the
above mentioned reasons.Also first 300 requests execute
successfully.otherwise this error should have come at the first
request itself.
Can anyone please help us?
Thanks in advance.
Don
 
C

Chris Tanger

I have a similar problem while trying to instantiate an
RSACryptoServiceProvider for the 30th time or so in a C# dll class.
Basically I have multiple threads using the RSACryptoServiceProvider and
periodically about 1 every 30 tries I get the same error you are getting. I
am wondering if the underlying cryptoAPI in windows is threadsafe or not.

Look for my post to Microsoft in dotnet.framework
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top