How to get X509Certificate from certificate store and generate xml signature data?

后端 未结 1 1600
无人及你
无人及你 2020-12-15 06:09

How can I get X509Certificate from certificate store and then generate XML SignatureData in .net C#?

相关标签:
1条回答
  • 2020-12-15 06:42

    As far as I know, 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);
    
            store.Open(OpenFlags.ReadOnly);
            X509Certificate2Collection cers = store.Certificates.Find(X509FindType.FindBySubjectName, "My Cert's Subject Name", false);
            if (cers.Count>0)
            {
                cer = cers[0];
            };
            store.Close();
       }
    
    0 讨论(0)
提交回复
热议问题