Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.NET证书(C#)_C#_.net_Asp.net_Ssl Certificate_X509certificate - Fatal编程技术网

.NET证书(C#)

.NET证书(C#),c#,.net,asp.net,ssl-certificate,x509certificate,C#,.net,Asp.net,Ssl Certificate,X509certificate,我的网站正在做一些http文章到另一个服务器,我需要附加一个证书 我正在使用此代码打开证书存储并获取所需的证书: X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly); X509CertificateCollection certCollection = store.Certificates; 用户是一个域帐户,应用程序池使用它 问题是,只

我的网站正在做一些http文章到另一个服务器,我需要附加一个证书

我正在使用此代码打开证书存储并获取所需的证书:

X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
X509CertificateCollection certCollection = store.Certificates;
用户是一个域帐户,应用程序池使用它

问题是,只有当该帐户登录到计算机时,我才能获得证书。如果用户注销,我将无法访问此存储

有什么想法吗


谢谢

您需要将证书从CurrentUser windows证书存储移动到LocalMachine存储(例如,使用证书MMC控制台),然后将X509Store构造函数的参数从StoreLocation.CurrentUser更改为StoreLocation.LocalMachine


另一种选择是将证书存储在PFX文件中并从那里加载,但从磁盘加载PFX文件时需要注意密码的安全性。

您需要将证书从CurrentUser windows证书存储移动到本地计算机存储(例如,使用证书MMC控制台),然后将X509Store构造函数的参数从StoreLocation.CurrentUser更改为StoreLocation.LocalMachine

另一种选择是将证书存储在PFX文件中并从那个里加载,但您需要注意从磁盘加载PFX文件时使用的密码的安全性