Failed to import private key - how to overcome? (wodSFTP / wodSFTP.NET / wodSFTPdll)
I am struggling to connect to an SFTP server. I have the following code:
[code]
WeOnlyDo.Security.Cryptography.KeyManager keyM = new WeOnlyDo.Security.Cryptography.KeyManager();
keyM.Load(privateKeyFile, password);
WeOnlyDo.Client.FtpDLX wodFtpDLX = new WeOnlyDo.Client.FtpDLX();
wodFtpDLX.LicenseKey = licenseKey;
wodFtpDLX.Protocol = WeOnlyDo.Client.Protocols.SFTP;
wodFtpDLX.Authentication = WeOnlyDo.Client.Authentications.PublicKey;
wodFtpDLX.Hostname = ftpAddress;
wodFtpDLX.Login = userName;
wodFtpDLX.PrivateKey = keyM.PrivateKey(WeOnlyDo.Security.Cryptography.SSHKeyTypes.RSAKey);
wodFtpDLX.Blocking = true;
wodFtpDLX.Connect();
[/code]
If the private key password is incorrect, I get the Failed to import private key error immediately so I know the key is being loaded without issue. The error is only being raised when I try to connect to the server. It is immediate so I am guessing it is when the key is trying to be loaded on to the client. Have I set any of the properties incorrectly or are there any which I have failed to set?
Much appreciated.
Re: Failed to import private key - how to overcome
Hi Paul,
You need to load private key inside PirvateKey Property in XML folder. In order to do that you can try something like this:
[code]wodFtpDLX..PrivateKey = keyM.ToXmlString(WeOnlyDo.Security.Cryptography.SSHKeyTypes.RSAKey, true);[/code]
Let us know how it goes.
Regards,
Drazen
Re: Failed to import private key - how to overcome
Hi Drazen,
That worked! Thanks very much for the perfect reply in a very timely manner.
Re: Failed to import private key - how to overcome
Paul,
No problem that's why we are here.
If you need some help please don't hesitate to ask. We are here to help you.
Drazen