X509Certificate2 方法出错:系统找不到指定的文件

来源:互联网 发布:说话打字的软件 编辑:程序博客网 时间:2024/06/05 02:54

在window server 2012R2中部署网站后,银行支付接口出错。

网上找到一个解决办法:将证书开放USER的读取权限,这样才能访问证书。试了以后还是一样报错,明天再试试其他办法。



 问题解决了,把原来的X509Certificate2 x509 = new X509Certificate2(strPathPfx, strPasswordPfx);

改为X509Certificate2 x509 = new X509Certificate2(strPathPfx.ToString(), strPasswordPfx.ToString(), X509KeyStorageFlags.MachineKeySet)

此方法中 X509KeyStorageFlags 的默认值是 DefaultKeySet ,加载时,会要求保存与 PFX 文件关联的密钥,但是又没指定密钥存储

0 0
原创粉丝点击