Pkcs12Store can't parse PFX file which doesn't contain certificate
Here is my scenario: Using the following openssl command to generate the pfx file which doesn't contains cert:
openssl.exe genrsa -aes256 -out E:\Temp\test.pem -passout pass:123456 2048 2
openssl.exe pkcs12 -keypbe PBE-SHA1-3DES -aes256 -export -nocerts -inkey E:\Temp\test.pem -out E:\Temp\test.pfx -passin pass:123456 -passout pass:123456
I am trying to parse the key out of the pfx file using bouncy castle. here is the simple code:
string psw = "123456";
string pfxPath = @"E:\Temp\test.pfx";
using (Stream stream = File.Open(pfxPath, FileMode.Open))
{
Pkcs12Store pkcs = new Pkcs12StoreBuilder().Build();
pkcs.Load(stream, psw.ToArray());
}
However, pkcs is empty. I think it is because the PFX file doesn't have a certificate. So my question is: is there a way that bouncy castle can handle this situation?
Pkcs12Store
It looks like in the pkcs "src" folder there is no implementation/logic for SymmetricKey (SecretKey) retrieval!
It would be really great if it can have something like - public SymmetricKeyEntry GetKey(string alias) { ... } and/or related properties & methods to handle "SymmetricKey / SecretKey" entries! Thanks in advance to the x-man who will be contributing to this one :)