G
Guest
I have a multithreaded server application where each thread
instantiates and uses the RSACryptoServiceProvider class when needed. During
testing there can be as many as 100 threads attempting to instantiate
RSACryptoServiceProvider simultaneously. When this happens, most of the
time, but not always about 3 of the threads throw the following exception
while attempting RSACryptoServiceProvider instantiation.
"CryptoAPI cryptographic service provider (CSP) for this implementation
could not be acquired."
Is the underlying CryptoAPI not threadsafe? Or can it just not handle too
many instantiations in close succession, perhaps because of not being able to
cleanup its resources fast enough.
Should I mark code that uses RSACryptoServiceProvider as a critical section
by using lock statements?
NOTE: When my application has been released to production there could be as
many as 500-1000 close succession instantiations of RSACryptoServiceProvider.
I also saw a post that appeared to have a similar problem on 10/25/2004 by
Don Nelson in dotnet.framework.aspnet.security
instantiates and uses the RSACryptoServiceProvider class when needed. During
testing there can be as many as 100 threads attempting to instantiate
RSACryptoServiceProvider simultaneously. When this happens, most of the
time, but not always about 3 of the threads throw the following exception
while attempting RSACryptoServiceProvider instantiation.
"CryptoAPI cryptographic service provider (CSP) for this implementation
could not be acquired."
Is the underlying CryptoAPI not threadsafe? Or can it just not handle too
many instantiations in close succession, perhaps because of not being able to
cleanup its resources fast enough.
Should I mark code that uses RSACryptoServiceProvider as a critical section
by using lock statements?
NOTE: When my application has been released to production there could be as
many as 500-1000 close succession instantiations of RSACryptoServiceProvider.
I also saw a post that appeared to have a similar problem on 10/25/2004 by
Don Nelson in dotnet.framework.aspnet.security