IIS 无权访问证书存储

IIS has no access to Certificate Store

我对 IIS 或 Visual C# 不是很熟悉,

但最近我想在我们可以在我们的云应用程序中使用的 Web 服务中的 .dll 文件中包装一个服务控制器。

我用 C# 写了一个简短的脚本 post 关于 Http WebAPI 的信息,并将依赖程序集的功能包装在其中。

我可以在我的本地计算机上访问证书存储区。即使当我 运行 app.exe 或来自 localhost:5000 中的 IIS Express 时,它也可以作为网络应用程序工作,可以看到证书密钥库。

当我 运行 它来自 IIS 10 或服务器 public 时,它无法识别证书。[​​=12=]

The image is in the same localhost within the server. Running on IIS Express from webbapp.exe on the left and IIS10 on the right.

根据与本地 IIS Express 的比较,知道 IIS 出了什么问题吗?我能做些什么来修复它还是应该找到任何其他解决方法。

正如@LexLi 所建议的那样,IIS 仅限于访问 KeyStore。配置为 运行,因此 dll 试图访问

X509Store(StoreName.My, StoreLocation.CurrentUser);

问题是 ISS 出于安全目的无法访问该用户。 经过一些调整后,我更改为:

X509Store(StoreName.Root, StoreLocation.LocalMachine);

并且在我的 运行 应用程序池的 "Advances Settings" 下的 IIS 10 "Application Pool" 下。我做了以下

Identity: LocalSystem
Load User Profile: True

现在似乎一切正常。