I've recently discovered OpenSSL.NET and it's a pretty sweet little wrapper.
I'm trying to execute the following code:
public static void DoSomething(byte[] buf)
{
OpenSSL.Core.BIO input = new OpenSSL.Core.BIO(buf);
OpenSSL.X509.X509Certificate b = OpenSSL.X509.X509Certificate.FromPKCS12(input, "passphrase");
OpenSSL.Core.BIO outs = OpenSSL.Core.BIO.MemoryBuffer(false);
b.PrivateKey.WritePrivateKey(outs, OpenSSL.Crypto.Cipher.Null, "passphrase");
outs.SetClose(OpenSSL.Core.BIO.CloseOption.Close);
Console.WriteLine(outs.ReadString());
}
Problem comes at the "b.PrivateKey.WritePrivateKey(.." line. I want to write the private key out without any encryption. According to spec, if I use a Null cipher type this should do the trick, but it never works, regardless of the cert I use in buf.
Here's the exception:
error:0D0A706C:asn1 encoding routines:PKCS5_pbe2_set:cipher has no object identifier error:2307D00D:PKCS12 routines:PKCS8_encrypt:ASN1 lib
I know this part works fine because if I specify any other cipher type, it exports the private key without fail. Anyone have any suggestions?