I have PKCS12 file (secured by password) which contains Aux key and main key generated using aux key.
Now I am trying to read the keys programmatically in C#.
Please let me know am I missing something? or the approach I am following is not correct? If so, please share how to achieve it without any third party paid library
What I have tried:
1. Key store explorer
Using key store explorer, I can read the key using password, but I want to
do it programmatically.
2. Pkcs12Store (Org.BouncyCastle.Pkcs)
Pkcs12Store store = new Pkcs12Store(new FileStream(jksFilePath,
FileMode.Open, FileAccess.Read), passWord.ToCharArray());
Here I am not getting any exception but store returns 0 key count.
3. Using X509Certificate2Collection and X509Certificate2
X509Certificate2Collection collection = new X509Certificate2Collection();
collection.Import(jksFilePath, passwordToOpenJKS,
X509KeyStorageFlags.DefaultKeySet);
Here, I collection does not contains any key
4. using X509Certificate2
X509Certificate2 cert = new X509Certificate2(jksFilePath, secString,
X509KeyStorageFlags.UserKeySet);
Here I am getting an error "Parameter incorrect". I have tried all
possible X509KeyStorageFlags