fail to connect by public key (wodSFTP / wodSFTP.NET / wodSFTPdll)

by Jasmine, (3025 days ago) @ simonasuciu

Hi Simona,

please do not used that key anymore since you've shared it, generate new one for your usage.

I have managed to get your code running using wodKeys too. Here's the scenario. pKeys->GetPrivateKey returns BSTR, which you have to convert to (char *), and tha'ts what SetPrivateKey should have failed.

You can also use GetPrivateKeyData which returns SAFEARRAY, and you can handle that array as (char *). Code would be like this:

[code]
SAFEARRAY *psa = pKeys->GetPrivateKeyData(/*SSHKeyTypes::*/RSAkey);
void *data = NULL;
long lbound, ubound; // get array bounds
SafeArrayGetLBound(psa, 1 , &lbound);
SafeArrayGetUBound(psa, 1, &ubound);

SafeArrayAccessData(psa, &data);
Sftp_SetPrivateKey(handle, data, ubound-lbound+1);
SafeArrayUnaccessData(psa);
SafeArrayDestroy(psa);
[/code]

So, we access SAFEARRAY, extract data from it, pass to SetPrivateKey, and destroy SAFEARRAY. I tested that code and it works ok.

Let me know how it goes for you!

Best regards,
Jasmine.

locked

Complete thread: