How can I get X509Certificate from certificate store and then generate XML SignatureData in .net C#?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
AFAIK, certificates are not saved by XML Format , you should combine it by yourself.
Is this what you want ?
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();
}