X509Certificate2 cert = new X509Certificate2("CertificateFile.pfx", "password"); X509CertificateCollection certCollection = new X509CertificateCollection(); certCollection.Add(cert);
X509Certificate2 cert1 = new X509Certificate2("CertificateFile1.pfx", "password"); X509Certificate2 cert2 = new X509Certificate2("CertificateFile2.pfx", "password"); X509CertificateCollection certCollection = new X509CertificateCollection(); certCollection.Add(cert1); certCollection.Add(cert2);In this example, we create two instances of X509Certificate2 class by loading certificates from two different PFX files. Then, we create an empty X509CertificateCollection and add both certificates to it using the Add method. Package/Library: System.Security.Cryptography.X509Certificates is part of the .NET Framework Class Library.