11
如何從證書存儲獲取X509Certificate,然後在.net C#中生成XML SignatureData?如何從證書庫中獲取X509Certificate並生成XML簽名數據?
如何從證書存儲獲取X509Certificate,然後在.net C#中生成XML SignatureData?如何從證書庫中獲取X509Certificate並生成XML簽名數據?
AFAIK,證書不是通過XML格式保存的,你應該自己組合它。
這是你想要的嗎?
static void Main(string[] args)
{
X509Certificate2 cer = new X509Certificate2();
cer.Import(@"D:\l.cer");
X509Store store = new X509Store(StoreLocation.CurrentUser);
store.Certificates.Add(cer);
X509Certificate2Collection cers = store.Certificates.Find(X509FindType.FindBySubjectName, "My Cert's Subject Name", false);
if (cers.Count>0)
{
cer = cers[0];
};
store.Close();
}
您需要調用「store.Open(OpenFlags.ReadOnly);」如果在查找之前未將證書添加到商店中,則在「查找」之前。 – aelstonjones 2013-10-09 20:12:46
'''使用System.Security.Cryptography.X509Certificates'''來獲取導入的名稱空間。 – 2016-03-21 22:47:33