【发布时间】:2015-10-26 15:55:42
【问题描述】:
我有一个安装 pfx 文件的 c# 程序(代码如下)
X509Certificate2 cert;
cert = new X509Certificate2(@"myCert.pfx", "password");
if (cert != null)
{
var store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite);
if (!store.Certificates.Contains(cert))
{
store.Add(cert);
}
}
当我在管理控制台中查看证书时,这似乎将证书添加到了正确的位置。但是,我在 c# 中有一个 websocket 服务器,它将从商店中挑选出来并将其用于与浏览器的 ssl 连接,但是由于没有对证书的身份验证,浏览器都失败了。
但是,如果我要手动安装它(单击证书)并将其安装到同一位置,一切正常。
注意:它是自签名的
我该如何解决这个问题
【问题讨论】: