Cannot instantiate KeyManager - WeOnlyDo Discussion board

Cannot instantiate KeyManager (General questions)

by Armin, Thursday, March 05, 2009, 09:22 (5741 days ago)

We are actually using the latest Version of WeOnlyDo.Client.SFTP (3.3.2.76) together with the latest Version of WeOnlyDo.Security.Cryptography.KeyManager (2.0.1.18). We need the Keymanager to load a PrivateKey from filesystem and populate the appropriate property of the SFTP Class (PrivateKey). It all works fine locally but on the production server it doesnt. At instantiation of the KeyManager we are receiving this error:

[...]
OPENSSL_add_all_algorithms_noconf() at WeOnlyDo.Security.Cryptography.KeyManager..ctor() at BLL.FTPManager.ConnectToSFTP(Boolean useKey)
[...]
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Re: Cannot instantiate KeyManager

by woddrazen, Thursday, March 05, 2009, 10:08 (5741 days ago) @ Armin

Hi Armin,


Can you maybe show us some code snippet how did you load your private key in wodKeyManager?

In order to deal with your problem we will need to duplicate it somehow.


Regards,
Drazen

Re: Cannot instantiate KeyManager

by Armin, Thursday, March 05, 2009, 10:15 (5741 days ago) @ woddrazen

Hey Drazen,

thanks for the fast reply.

The Code Snippet is fairly simple:


WeOnlyDo.Security.Cryptography.KeyManager KM = new WeOnlyDo.Security.Cryptography.KeyManager();

And the complete error message is:

Ads.Iposo.ProcessServer.Host.ComponentEntry.set_LastError: at OPENSSL_add_all_algorithms_noconf() at WeOnlyDo.Security.Cryptography.KeyManager..ctor() at ImportExport.SanofiImportMusterauslieferung.Execute(ExecutionInfo info) at Ads.Iposo.ProcessServer.Host.ComponentEntry.StartExecuteThread() Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Re: Cannot instantiate KeyManager

by woddrazen, Thursday, March 05, 2009, 10:30 (5741 days ago) @ Armin

Armin,


We will need code snippet when you Load PrivateKey using wodKeyManager Load MEthod.


Drazen

Re: Cannot instantiate KeyManager

by Armin, Thursday, March 05, 2009, 10:45 (5741 days ago) @ woddrazen

Well, that is exactly the point: I am not getting to the point where the key would be loaded. It crashes when it is getting instantiated. The CodeSnippet that I have sent you is my entire code. All the application is doing at the moment is to instantiate the keymanager. Everything else is commented. Locally on my machine, where everything is working as expected I am loading the key on this way:

SFTP _sftp = new SFTP();
_sftp.Blocking = true;
_sftp.ListItemsEvent += new WeOnlyDo.Client.SFTP.ListItemsDelegate(this.sftp1_ListItemsEvent);
_sftp.StateChangedEvent += new WeOnlyDo.Client.SFTP.StateChangedDelegate(this.sftp1_StateChangedEvent);
_sftp.Disposed += new EventHandler(_sftp_Disposed);
_sftp.LoopItemEvent += new SFTP.LoopDelegate(_sftp_LoopItemEvent);
_sftp.AttributesEvent += new SFTP.AttributesDelegate(_sftp_AttributesEvent);

WeOnlyDo.Security.Cryptography.KeyManager KM = new WeOnlyDo.Security.Cryptography.KeyManager();
try
{
_sftp.Port = 22;
_sftp.Timeout = 60;

_sftp.PrivateKey = KM.PrivateKey( KM.Load( PathToKey ) );
_sftp.Hostname = HostIp;
_sftp.Authentication = SFTP.Authentications.PublicKey;

Log.Information( SFTP CONNECTING! );
_sftp.Connect();


}
finally
{
KM = null;
}

Re: Cannot instantiate KeyManager

by woddrazen, Thursday, March 05, 2009, 13:26 (5741 days ago) @ Armin

Armin,


I have just tried and it worked for me.

Can you please try something like this:
http://www.weonlydo.com/index.asp?kb=1&View=entry&EntryID=62


Drazen