vb.netrpcx509certificate2cryptographicexception

Errors Loading X509 Certificate


For the last week I have been finding the following two intermittent exception on our web servers:

System.Security.Cryptography.CryptographicException: Insufficient system resources exist to complete the requested service.

System.Security.Cryptography.CryptographicException: The RPC server is too busy to complete this operation.

The exception only occurs on a small percentage of attempts, and is thrown on this line of code:

Return New X509Certificate2(AppSettings("EESSLFile"), AppSettings("EESSLPassword"))

The first AppSetting is a network path to a .p12 certificate file, and the second is the password which opens it.

I cannot for the life of me figure out what is causing the problem. Google doesn't seem to have any results for "CryptographicException" combined with either "Insufficient system resources" or "The RPC server is too busy".

We have three web servers in an equally distributed web farm. I wondered whether it's a case of the file being in use, but it seems to occur from different web servers in batches and I would expect to see the error spread across them all at the same time if that was the case.

I'm wondering if the Cryptography part is just a red herring to another underlying issue, but I'm really stuck for ideas, so if anyone knows what is going on, please let me know.


Solution

  • I eventually solved this by using a workaround. The root cause of the problem is still unknown.

    The workaround was to install the .p12 file into the Certificate Store and load it from there for each request, rather than reading from the file.