I am trying to use OpenSSL.net library to generate a public / public key pair for encryption. I added the ManagedOpenSsl.dll to the references and put libeay32.dll and ssleay32.dll into my working directory (As described here)
Unfortunately I get a nasty exception when running the code (it builds fine). What am I doing wrong here?
EDIT code modified:
public void GetKeys ()
{
using( OpenSSL.Crypto.RSA test = new OpenSSL.Crypto.RSA() )
{
test.GenerateKeys( 1024, 65537, null, null );
string privKey = test.PrivateKeyAsPEM;
string pubKey = test.PublicKeyAsPEM;
MessageBox.Show( privKey, "Private Key" );
MessageBox.Show( pubKey, "Public Key" );
}
}
This is the exception error I get says "SystemTypeInitializationException".
It seems to be the libeay32.dll and ssleay32.dll files are not present in the output folder after build. Please check the properties of that files and make sure that "Copy to Output Directory" is marked as "Copy Always". After build process the files must be in x86 or x64 subfolders depending the version of the library which you're using.