Swa
Swa

Reputation: 39

How to import a pfx file with multiple cert to a x509 collection

I have code which gets a collection of certs as base64 and write it as a pfx file. But I need as a cert collection to iterate it and find the right cert for my logic.

File.WriteAllBytes(cert.pfx, colecctionofcertinbytes); // I dont want this to treat collection of cert as one cert and want to load it as a collection instead of a single cert X509Certificate2 cert = new X509Certificate2(colecctionofcertinbytes); // will this add it as a collection or a single cert? x509Certificatecollection.Add(cert);

Upvotes: 1

Views: 749

Answers (1)

Swa
Swa

Reputation: 39

X509Certificate2Collection collection = new X509Certificate2Collection();
collection.Import(certPath, certPass, X509KeyStorageFlags.PersistKeySet);

Upvotes: 2

Related Questions