C#x509Store访问网络托管

发布于 2025-02-09 14:28:40 字数 380 浏览 1 评论 0原文

我在证书存储的网络托管文件夹中存储了一个SSL证书。我似乎无法从C#访问此商店。有人知道该怎么做吗?

 X509Store store = new X509Store("Web Hosting");
 store.Open(OpenFlags.ReadOnly);
 var t = store.Certificates.GetEnumerator();

 while (t.MoveNext())
 {
     //this is always empty
}

其他细节 我需要此证书来用于我正在写的GRPC服务。 GRPC需要SSL连接的证书。同时,我正在使用我们使用的加密来生成证书。当证书生成时,证书被放入证书商店的网络托管文件夹中。

I have an SSL cert stored in the Web Hosting Folder of the Certificate Store. I cannot seem to be able to access this store from C#. Does anyone know how to do this?

 X509Store store = new X509Store("Web Hosting");
 store.Open(OpenFlags.ReadOnly);
 var t = store.Certificates.GetEnumerator();

 while (t.MoveNext())
 {
     //this is always empty
}

Additional Detail
I need this cert for a gRPC service that I am writing. gRPC requires a certificate for the SSL connection. In the mean time aka development I am using Let's Encrypt to generate the certificate. When the cert was generated the cert was put into the Web Hosting folder of the cert store.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

雄赳赳气昂昂 2025-02-16 14:28:40

这有效:

var certStore = new X509Store("WebHosting");

This works:

var certStore = new X509Store("WebHosting");
烧了回忆取暖 2025-02-16 14:28:40

事实证明,您可以将证书拖放到证书经理中的其他位置。我将证书搬到了个人文件夹中,并且能够通过:

X509Store store = new X509Store(StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);

It turns out you can drag and drop the certs to a different location in the cert manager. I relocated the cert to the Personal folder and I was able to access it by:

X509Store store = new X509Store(StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
北方的巷 2025-02-16 14:28:40

尝试删除空间;例如,尝试将名称作为WebHosting(无空间)

在PowerShell中,以在此商店的位置显示证书:

dir cert:\localmachine\webhosting 

Try removing the space; e.g., try the name as webhosting (no space)

In PowerShell, to display certs in this store location:

dir cert:\localmachine\webhosting 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文