ASP.NET - The specified network password is not correct

前端 未结 2 2005
栀梦
栀梦 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.

提交回复
热议问题