我在阅读证书时遇到问题。我有网络服务,必须使用部分主题获取证书序列号。如果我从表单中进行操作,一切正常,但是当我从Web服务中尝试它时,它似乎找不到任何证书。我使用此代码阅读所有证书:
.grid-box {
display: flex;
flex-direction: column;
}
.first-row {
display: flex;
}
.grid {
border: 1px solid #fff;
overflow: hidden;
transition: all .3s linear;
}
.one, .two {
width: 100px;
height: 100px;
}
.three {
width: 202px;
height: 100px;
}
.grid:hover img {
transform: scale(2);
transition: all .2s linear;
}
答案 0 :(得分:0)
您正在使用parameterless constructor for X509Store,根据文档,它将为当前用户打开证书存储区。那么,表单应用程序的当前用户可能与您的Web应用程序的当前用户不同,后者很可能在配置为使用服务帐户的AppDomain中运行。这意味着Web应用程序无法找到它。
要解决此问题,您有两个选择
首先将您的证书存储在机器商店(而不是用户商店)中。然后,在您的代码中,使用a different constructor打开商店,您可以指定store location,并指定您想要机器商店。像这样:
var store = new X509Store(StoreLocation.MachineStore);
维护两份证书。请按照以下步骤操作:
runas /user:MyDomain\MyServiceAccount "cmd /c start /B certmgr.msc"
。出现提示时,请确保告诉它您要使用当前用户的证书存储区,而不是机器存储区。