X509Certificate2 - the system cannot find the path specified X509Certificate2 - the system cannot find the path specified asp.net asp.net

X509Certificate2 - the system cannot find the path specified


If you are running in IIS, you need to set "Load User Profile" to True in the application pool's advanced settings to be able to load a cert by filename & password.


So, I just had the exact same problem. I tried to solve it for almost 4 hours.

Problem was in passed path to key. Because I used the code from Google sample console application, where the path was just "key.p12" and the key was in the same directory as the exe file.

And when I wanted to create MVC application, I did not realize, that root of virtual server path can not be called just like "key.p12".

SOLUTION

Double check the path to the key. If it is MVC application (or another ASP web), then add the key file to the root and in code call the key by using Server.MapPath("key.p12").


I just had the same issue, in my case it was a space in the path. I have no idea why, but when I put the p12 file on c:\ root, it's working...