Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP Error 500.30 (Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: The system cannot find the file specified.)

I am trying to deploy the asp.net core Web API to the IIS. This application works perfectly fine on the Visual studio and also when I run the dll using the dotnet command. This application has the certificate for signing the JWT token. After deploying the application to IIS I am getting "HTTP Error 500.30 - ANCM In-Process Start Failure" and I checked the windows log and error message is

Host terminated unexpectedly. Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: The system cannot find the file specified.at Internal.Cryptography.Pal.CertificatePal.FilterPFXStore(Byte[] rawData, SafePasswordHandle password, PfxCertStoreFlags pfxCertStoreFlags)......

I checked the file path and file name everything is correct but some reason IIS is not able to load find the certificate file. Also, I checked the permission and it also looks good. Not sure why I am getting this error message

Also, I ran the same application dll file using the dotnet run command where IIS is pointing to but I am not getting any error. I am getting this error only after deployng to IIS.

On startup.cs file and configuration method I am getting error on this line.

var cert = new X509Certificate2("test_cert.pfx", pwdFrmVault);
like image 994
LilRazi Avatar asked Mar 02 '23 05:03

LilRazi


1 Answers

I after searching for this error and googling, this solution worked for me. IIS Manager->application pool -> advanced settings ->Under Process model, Load User Profile to true. More detail on link

like image 168
LilRazi Avatar answered Mar 05 '23 17:03

LilRazi