简体   繁体   中英

How to create X509Chain with more than one element?

I simply want to use a X509Chain but I don't know how to create it. I have certificates but I don't know how to put in the chain more than one certificate. I looked in MSDN and there I saw a sample that shows to creat the X509Chain like that:

X509Chain ch=new X509Chain();
ch.Build(X509Certificate2);

so I created one X509Certificate2 and inserted it to the Build(), but I don't know how can I add the other sub certificates of my chain.

X509Chain.Build() method expects to get one leaf certificate to build up from it all the chain. The build method looks for the certificates chain on the local computer certificate store, if you want to build chain from certificates that weren't installed on the computer store, you can generate your own store by:

X509Chain.ChainPolicy.ExtraStore.Add(X509Certificate2 RootCertificate);

and then perform:

X509Chain.Build(LeafCertificate);

to build the chain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM