简体   繁体   English

无法从X509Store读取CurrentUser证书

[英]Can't read CurrentUser certificates from X509Store

I'm developing ASP.NET 4.0 web application, and I want to read the current user certificates from X509Store. 我正在开发ASP.NET 4.0 Web应用程序,并且想从X509Store中读取当前的用户证书。 Reading the LocalMachine certificates works fine, but if I set the StoreLocation to CurrentUser, it gives me an empty collection. 读取LocalMachine证书可以正常工作,但是如果我将StoreLocation设置为CurrentUser,它会给我一个空集合。

The following code works fine : 以下代码可以正常工作:

X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine); // StoreLocation.CurrentUser
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);

I've checked my personal store (via certmgr.mmc) and I'm sure that I have the certificates. 我已经检查了我的个人商店(通过certmgr.mmc),并且确定我具有证书。

What am I missing ? 我想念什么? ( store.Certificates is empty ) (store.Certificates为空)

It appears that you can not access the Personal Certificate Store via web application, no matter what application pool identity you're using. 似乎无论您使用什么应用程序池标识,都无法通过Web应用程序访问“个人证书存储”。

It makes sense, a web application has no access to that location. 有道理,Web应用程序无法访问该位置。 :) :)

My solution : 我的解决方案:

I've developed an ActiveX control which I think its the only way to access the Store. 我已经开发了ActiveX控件,我认为它是访问商店的唯一方法。 (Also, a Java Applet offers the same functionality). (此外,Java Applet提供相同的功能)。 I use the ActiveX control via JavaScript to access the Store, and send that information to the server. 我通过JavaScript使用ActiveX控件来访问商店,并将该信息发送到服务器。

If your worker process cannot access cert store, maybe it's just account setup problem. 如果您的工作进程无法访问证书存储,则可能仅仅是帐户设置问题。 Try go ing to IIS Configuration, open ApplicationPools, right click on yours, select Advanced and try setting LoadUserProfile to TRUE. 尝试转到IIS配置,打开ApplicationPools,右键单击您的,选择Advanced,然后尝试将LoadUserProfile设置为TRUE。 And restart the pool. 并重新启动池。 It worker for me - no more exceptions when loading .PFX with private keys. 它为我工作-用私钥加载.PFX时没有更多异常。

I had a similar problem. 我有一个类似的问题。 The solution was: 解决方案是:

IIS admin->[your virtual dir]->Authentication->Anonymous Authentication (select then click "Edit...") and change it to use "Application pool identity". IIS管理员-> [您的虚拟目录]->身份验证->匿名身份验证(选择然后单击“编辑...”),然后将其更改为使用“应用程序池标识”。

Otherwise it may be running as the generic "IUSR" 否则,它可能会作为通用“ IUSR”运行

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

相关问题 从 X509Store 频繁检索证书 - Frequent retrieval of certificates from X509Store 如何从 X509Store 加载受密码保护的证书? - how to load password protected certificates from the X509Store? .NET的X509Store可以用于从远程Linux商店获取证书吗? - Can .NET's X509Store be used to get certificates from remote Linux stores? 如何检索 X509Store 中的所有证书 - How to retrieve all certificates in your X509Store X509Store证书。查找FindByThumbprint - X509Store Certificates.Find FindByThumbprint X509Store 证书问题。查找 FindByThumbprint - Problems with X509Store Certificates.Find FindByThumbprint 无法使用指纹从 asp.net core 2.1 访问 X509Store 中的证书 - Cant access certificates in X509Store from asp.net core 2.1 with thumbprints Azure应用服务:在X509Store(StoreName.My,StoreLocation.CurrentUser)中找不到证书 - Azure app service: Cannot find the certificate in X509Store(StoreName.My, StoreLocation.CurrentUser) 由于X509Store中的store.Open和store.Certificates.Find方法而导致的性能影响 - Performance impact due to store.Open and store.Certificates.Find methods in X509Store 使用 X509Store 导入证书时无法使用 netsh 绑定证书 - Can't bind cert using netsh when importing it with X509Store
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM