Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException–The system cannot find the file specified
After deploying an application to production, it failed with the following error message:
The system cannot find the file specified
Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: at Internal.Cryptography.Pal.CertificatePal.FilterPFXStore (System.Security.Cryptography.X509Certificates, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) at Internal.Cryptography.Pal.CertificatePal.FromBlobOrFile (System.Security.Cryptography.X509Certificates, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) at System.Security.Cryptography.X509Certificates.X509Certificate..ctor (System.Security.Cryptography.X509Certificates, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor (System.Security.Cryptography.X509Certificates, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
Let’s take a look at the code that caused this issue:
Not much I could do wrong with this code. It tries to load a PFX file from disk and open it using the specified password.
I checked if the file was there and that was indeed the case. So we have to search for the root cause somewhere else.
I took a look at the Application Pool settings and noticed that the Load User Profile setting was set to False.
Aha! After changing this back to True the error got away…