I’m trying to read the pkcs12store to extract the private certificate and the chain of certificate. The pfx file is protected by a password. If the password is empty everything works fine, but if it holds a value it fails with the following error. Any help to resolve this would be appreciated.
var pk12 = new Pkcs12Store(new MemoryStream(privateKeyBytes), "test".ToCharArray());
Exception:
System.AggregateException: One or more errors occurred. (PKCS12 key store MAC invalid - wrong password or corrupted file.) System.IO.IOException: PKCS12 key store MAC invalid - wrong password or corrupted file at Org.BouncyCastle.Pkcs.Pkcs12Store.Load(Stream input, Char[] password)