I have .NET web application where trying to import the certificate using the “X509Certificate2”. While importing, getting the “The specified network password is not correct.”. The certificate is password protected “.pfx” file and I’m providing the password too while importing the certificate. Here are the steps to produce the issue:
- In Global.asax.cs file, loading/importing the certificate on Application_Start by using:
X509Certificate2 cert = new X509Certificate2(“path_to_pfx_certificate_file”),
“password”,X509KeyStorageFlags.MachineKeySet);
It’s breaking and throwing the exception “The specified network password is not correct”.
enter image description here
I tried multiple solutions like:
- Setting user profile true in IIS
- Setting up multiple key flags like (DefaultKeySet, MachineKeySet, UserKeySet etc)
But nothing works.
Any help would be appreaciated.
Nabeel Farooq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.