I have two certificates that I saved to disk. One is a certificate with private key that I exported as a .pfx file, the other one is a certificate that I saved including its certificate chain as a PKCS#7 file ("certchain.p7b").
In C# I can now load the .pfx file with
var cert = new X509Certificate2(myPfxFileStream);
(myPfxFileStream is a FileStream opened to the .pfx File for reading), however trying the same thing with the PKCs#7 Certificate fails in a CryptoGraphicException "Der Indexwert ist ungültig" which translates to "invalid index value".
I assume I have to parse PKCS#7 diffenently (it contains a chain, not a single certificate!), but how?
(Oh, by the way: Currently I have no passwords on those certficiates)