【发布时间】:2014-09-18 00:56:25
【问题描述】:
在将签署文档的 Web 应用程序 (aspx/C#) 中,如何列出位于用户 USB 密钥(身份验证/签名密钥)上的证书?
这是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Signature1
{
public partial class signature : System.Web.UI.Page
{
string strTxt = "Certificates : ";
protected void Page_Load(object sender, EventArgs e)
{
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
foreach (X509Certificate2 cert in store.Certificates)
{
strTxt += "\nDélivered to " + cert.SubjectName.Name + " by " + cert.IssuerName.Name;
}
store.Close();
myTextbox.Text = strTxt ;
}
}
}
此代码在本地机器上运行良好(调试模式),但在应用服务器上发布时返回一个空列表。
感谢您的帮助。
【问题讨论】:
标签: usb x509certificate digital-signature x509