简体   繁体   English

Windows 2008 R2从IIS访问证书存储的权限

[英]Windows 2008 R2 permissions for accessing certificate stores from IIS

I'm creating web application what has to require client certificates for authentification. 我正在创建Web应用程序,它需要客户端证书进行身份验证。 After it user have to sign some text by his private key and send it to server. 之后,用户必须使用其私钥对一些文本进行签名并将其发送到服务器。 When data was received I need to decrypt it using users open key what is already stored at server at "other people" certificate store. 接收到数据后,我需要使用用户打开密钥对其进行解密,该存储已存储在“其他人”证书存储区的服务器上。 Also I need to check is this user's certificate in "not trusted store". 我还需要检查的是“不可信存储区”中此用户的证书。 Here is my c# code. 这是我的C#代码。

X509Store store = new X509Store(StoreName.My);
store.Open(OpenFlags.ReadOnly);
int Count = store.Certificates.Count;
foreach (X509Certificate2 mCert in store.Certificates)
{
    ClientName2 = mCert.Subject;
}

        store.Close();

But after I run it no certificates are found at personal store. 但是我运行它后,在个人商店中找不到证书。 But I see tham at certmgr.msc The similar situation is with other stores - some certificates can be accessed and some not. 但是我在certmgr.msc上看到了tham。其他商店也有类似情况-有些证书可以访问,有些不能访问。 I think that windows 2008 r2 server permissions for ApplicationPoolIdentity do not alow to get public user's certificates. 我认为Windows 2008 r2服务器对ApplicationPoolIdentity的权限不允许获得公共用户的证书。 But I can be wrong... Can you tell me how can I check permissins for storages access from iis? 但是我可能是错的...您能告诉我如何检查Permissins从iis进行存储访问吗? Or maybe I need to use other approach? 还是我需要使用其他方法?

24 Feb 2013 (edit): Yes, it seems that this issue is due to IIS permissions. 2013年2月24日(编辑):是的,似乎此问题是由于IIS权限引起的。 If I run console application with the same code everything works. 如果我使用相同的代码运行控制台应用程序,则一切正常。 Does everybody know how to set read permissinos for certificate stores at windows 2008 r2? 每个人都知道如何在Windows 2008 R2上为证书存储设置读取权限吗?

Here is my solution what I found some days after post this question. 这是我发布此问题几天后发现的解决方案。 There were several issues in my code but for this question I need to be attentive where certificates are added. 我的代码中有几个问题,但是对于这个问题,我需要注意添加证书的位置。

I added certificates at certmgr.msc and IE. 我在certmgr.msc和IE中添加了证书。 And they was added automatically to user certificate store but IIS looks for certificates at computer certificate store ! 并且它们被自动添加到用户证书存储中,但是IIS在计算机证书存储中查找证书 So when I ran console application from my current user application see users certificate. 因此,当我从当前用户应用程序中运行控制台应用程序时,请查看用户证书。 And IIS looks at other place. IIS则在其他地方。 If you want your certificates be visible at IIS add them to local computer storage via mmc console. 如果希望证书在IIS上可见,请通过mmc控制台将其添加到本地计算机存储中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM