0 votes
by (140 points)

Hi

We have Putty private and public key byte[] saved in db table. Using a very old version of rebex we were using private key byte[] to create SshPrivateKey object. Now trying to use latest rebex and byte[] is not working any more. Is there a way to use private key byte[] to create SshPrivateKey object in latest version?

Thanks

Applies to: Rebex SFTP

1 Answer

0 votes
by (147k points)

Hi, we are not aware of any change to SshPrivateKey(byte[] data, string password = null) constructor that would prevent it from loading private keys that worked previously. Please let us know how the issue manifests itself and we will look into it. If it throws an exception, copy&paste the output of its ToString() method here.

by (140 points)
Hi Lukas, thank you for replying. It throws exception, output of ToString() method is below.

System.Security.Cryptography.CryptographicException: Invalid key format.
at Rebex.Security.Cryptography.Pkcs.PrivateKeyInfo.lfxz(Byte[] ccz, Int32 cda, pvvf& cdb, KeyAlgorithm& cdc, String& cdd)
at Rebex.Security.Cryptography.Pkcs.PrivateKeyInfo.Load(Stream input, String password)
at Rebex.Net.SshPrivateKey.worq(Stream adu, String adv)
at Rebex.Net.SshPrivateKey..ctor(Byte[] data, String password)
by (140 points)
FYI, I am using the trial version of File Transfer Pack. If I create SshPrivateKey using .ppk file then it works.
by (140 points)
Hi Lucas, the issue has been resolved. The key string in the db table was only the private part of the .ppk file, not the entire ppk file content. I changed it and now it's working.
by (147k points)
Hi, thanks for letting us know! I was just about to send you a hotfix that enhances the error message to make it possible to determine why exactly it failed - we'll include this enhancement in one of the next releases to make issues like this easier to resolve in future.
by (140 points)
Thanks for the enhancement.
by (147k points)
The latest release (2019 R4.1) will report more meaningful errors that just "Invalid key format.": https://www.rebex.net/sftp.net/history.aspx#2019R4.1
...