0

我需要填充系统证书。当我在 VS 下调试它时,相同的源代码告诉我证书计数正确。当我在IIS 7.5 Windows 7下运行代码时,.Count总是返回0。有没有权限问题?为什么计数返回 0?

        System.Security.Cryptography.X509Certificates.X509Store store = new System.Security.Cryptography.X509Certificates.X509Store(System.Security.Cryptography.X509Certificates.StoreName.My);
        store.Open(System.Security.Cryptography.X509Certificates.OpenFlags.ReadOnly);
        Response.Write("<hr>Certs count: " + store.Certificates.Count.ToString() + "<br>");
4

2 回答 2

0

IIS and VS debugger run under different user credentials. So IIS cannot load the certificates. Here is my workaround:

I'll make a commandline utility and run it as user

于 2013-02-20T09:22:16.790 回答
0

ASP.NET 模拟有助于加载用户的证书。

PS:System.Security.Principal.WindowsIdentity.GetCurrent().Name 获取用户名。

于 2013-02-20T12:15:06.513 回答