ASP.NET - The specified network password is not correct

前端 未结 2 2006
栀梦
栀梦 2020-12-08 10:38

I have in my dev machine a WCF Client which requires certificate and it is working fine.
After the deployment to production server I get the following Error:

相关标签:
2条回答
  • 2020-12-08 11:15

    Try this:

    new X509Certificate2(Path, "", X509KeyStorageFlags.MachineKeySet); 
    

    It appears that the X509Certificate2 constructor tries to access the private key store of the local user (even when loading a PFX and the private key is in the PFX). With asp.net, the user profile typically isn't loaded, so the user key store doesn't exist. Specifying MachineKeySet tells the constructor to look at the Local Computer key store which always exists.

    0 讨论(0)
  • 2020-12-08 11:24

    I had this issue in with a PFX certificate file that had a 40 character password set, Windows allowed me to export it and also import it, but it couldn't be used in C# code, so I changed to a 30 character password and it works.

    0 讨论(0)
提交回复
热议问题