I have an instance of X509Certificate2 and get its PrivateKey property, which is RsaCryptoServiceProvider . MSDN that this RsaCryptoServiceProvider class RsaCryptoServiceProvider not thread safe. Therefore, if you are given some kind of X.509 evidence, I need to perform asymmetric encryption on multiple threads (typically on a web server), what is the best way to create multiple instances of RsaCryptoServiceProvider ?
The X509Certificate2 private key X509Certificate2 not marked as exportable, so I canβt just export the parameters on the source RsaCryptoServiceProvider and re-import them into another instance to bypass thread safety issues.
I got the original through the X509Store , but this seems to be a collection of X509Certificate2 instances, so if I want a new RsaCryptoServiceProvider instance, I need to create a new X509Store to find the new X509Certificate2 to get the new RsaCryptoServiceProvider . It just seems awfully hard to just force .NET to clone an instance of RsaCryptoServiceProvider .
Are there any better ways?
source share