No value in PrivateKey property. - WeOnlyDo Discussion board

No value in PrivateKey property. (General questions)

by Rob, Friday, July 06, 2007, 14:23 (6350 days ago)

Hi Guys,

I'm trying to use the DLL's in Microsoft Dynamics AX, wich has its own language called X++.
And it can use DLL's.
i wrapped the DLL's.

PRO_Sftp_SFTPCom sftp = new PRO_Sftp_SFTPCom();
PRO_Sftp_KeyKeys keys = new PRO_Sftp_KeyKeys();
comVariant privateKey = new comVariant();
str test;
;
keys.Load('c:\DSAkey.txt');

sftp.Authentication(2);

sftp.Hostname('localhost');
sftp.Login('ftp');

test = keys.PrivateKey(1);

privateKey.bStr(keys.PrivateKey(1));
sftp.PrivateKey(privateKey);

but i get no value from keys.PrivateKey(1) ??
in PrivateKeyData there are a buch of numbers!
what am i missing here?

thnx,
Rob

Re: No value in PrivateKey property.

by wodDamir, Friday, July 06, 2007, 15:01 (6350 days ago) @ Rob

Hi Rob,

The reason to this is that perhaps key starts with zero ( 0 ) which in many languages means end of string that could couse this.

Why exactly do you even need PrivateKey value? If you really need it's value you can retrieve it from PrivateKeyData anyway.

Regards,
Damba

Re: No value in PrivateKey property.

by Rob, Friday, July 06, 2007, 15:10 (6350 days ago) @ wodDamir

Ok, that makes sence ;-)

wich part of the array PrivateKeyData holds the key then? all i see are numbers..

i know, im a nOOb at SSH stuff.
but if i can get this to work, we can SFTP from Dynamics, and Microsoft will know we did it with WOD!

Re: No value in PrivateKey property.

by wodDamir, Friday, July 06, 2007, 15:36 (6350 days ago) @ Rob

Rob,

The whole array actually contains the key. All of those numbers are the key. Nothing besides key is contained in the array.

Perhaps the following article would help you conect to a server using PublicKey Authentication:

http://www.weonlydo.com/index.asp?kb=1&View=entry&CategoryID=5&EntryID=55

The code is written for VB, but perhaps you could re-write it to work in Dynamics?

Regards,
Damba

Re: No value in PrivateKey property.

by Rob, Friday, July 06, 2007, 15:45 (6350 days ago) @ wodDamir

I already checked out that code.

the problem is that the wrapper made the sftp.privateKey methode like this:
// Description: Private key used for authentication.
COMVariant PrivateKey(COMVariant _PrivateKey = COMVariant::createNoValue())
{
COMVariant c = new COMVariant();

c = self.PrivateKey(_PrivateKey);
return c;
}
so i have to pass the key.privateKey(1) as/in a comvariant object.
wich can be a bStr, but from PrivateKeyData i get an array..
how do i make the array to a str?

this dous not work..
types = keys.PrivateKeyData(1);
privateKey.safeArray(types,COMVariantType::VT_I4);
sftp.PrivateKey(PrivateKey);
it give a error, 'Private key could not be determinated'

Re: No value in PrivateKey property.

by wodDamir, Friday, July 06, 2007, 16:07 (6350 days ago) @ Rob

Rob,

PrivateKey is a Variant type. Perhaps even sftp.PrivateKey = keys.PrivateKeyData should work. Can you try something like that?

Also, do you have that key as a String (containing ----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----)? Perhaps you could enter it manually into a string and pass it to sftp.PrivateKey Property?

That should work. If it doesn't we could probably add that possibility.

Regards,
Damba

Re: No value in PrivateKey property.

by Rob, Wednesday, July 11, 2007, 11:14 (6345 days ago) @ wodDamir

Ok!

Seems to work now!
i managed to change the interface class en the wrapper class so i can give the COM object 'Keys' to sftp.PrivateKey() : sftp.PrivateKey(keys)
and it connects fine now!

we will buy the DLL this afternoon, when we put the code in the live environment!

i will let u know when/if the full application is working!

thnx!
Rob