Jump to content


Photo

Unable to load private key


  • Please log in to reply
9 replies to this topic

#1 Mathewscw

Mathewscw
  • Members
  • 5 posts

Posted 22 September 2008 - 02:44 PM

We recently purchased two licenses for the pro version which supports scripting. Was the PrivateKey property left out of the “Application” layer?

The following works fine, has it uses the library which I don’t need as I only have two servers…

Dim loEarlyConnection As sfFTPLib.SFTPConnection = New sfFTPLib.SFTPConnection        Dim loEarlyKeyManager As sfFTPLib.KeyManager = New sfFTPLib.KeyManager        loEarlyConnection.Host = "123.45.679.11"        loEarlyConnection.Username = "UserName"        loEarlyConnection.Port = 22        loEarlyConnection.LogFile = "c:\TestFTPLog.log"        loEarlyConnection.PrivateKey = loEarlyKeyManager.LoadFile("c:\Keys\PrivateKey.ppk", "")

Using the Application does not...

Dim loFTPApplication As Object = CreateObject("SmartFTP.Application")        Dim loConnection As Object = loFTPApplication.CreateObject("sfFTPLib.SFTPConnection")        Dim loKeyManager As Object = loFTPApplication.CreateObject("sfFTPLib.KeyManager")        loConnection.Host = "123.45.679.11"        loConnection.Username = "UserName"        loConnection.Port = 22        loConnection.LogFile = "c:\TestFTPLog.log"        <strong class='bbc'>loConnection.PrivateKey = loKeyManager.LoadFile("c:\Keys\PrivateKey.ppk", "")</strong>



Thanks

Edited by Mathewscw, 22 September 2008 - 02:56 PM.


#2 mb

mb

    Developer

  • Administrators
  • 11527 posts
  • Gender:
    Male
  • Location:
    Worldwide

Posted 22 September 2008 - 03:26 PM

What error do you get? Do you get an exception when assinging the PrivateKey?

Can you connect to the server? If yes can you post the log from the TestFTPLog.log.

Regards,
Mat

#3 Mathewscw

Mathewscw
  • Members
  • 5 posts

Posted 22 September 2008 - 03:40 PM

What error do you get? Do you get an exception when assinging the PrivateKey?

Can you connect to the server? If yes can you post the log from the TestFTPLog.log.

Regards,
Mat



The error I am receiving is…
VB.NET - {"Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))"}

In VB Script I receive Object doesn’t support this property or method.

And no I am unable to connect as this server requires authentication by use of a key. Thus the log file is empty.

#4 mb

mb

    Developer

  • Administrators
  • 11527 posts
  • Gender:
    Male
  • Location:
    Worldwide

Posted 22 September 2008 - 03:59 PM

The LoadFile method or the PrivateKey method?

#5 Mathewscw

Mathewscw
  • Members
  • 5 posts

Posted 22 September 2008 - 04:04 PM

The LoadFile method or the PrivateKey method?


The PrivateKey method.

#6 mb

mb

    Developer

  • Administrators
  • 11527 posts
  • Gender:
    Male
  • Location:
    Worldwide

Posted 22 September 2008 - 04:10 PM

Install the latest version of SmartFTP:
http://www.smartftp.com/download

Then register the sfFTPLib.dll:
regsvr32.exe sfFTPLib.dll

I think the proxy was not registered.

Regards,
Mat

#7 Mathewscw

Mathewscw
  • Members
  • 5 posts

Posted 22 September 2008 - 05:14 PM

Install the latest version of SmartFTP:
http://www.smartftp.com/download

Then register the sfFTPLib.dll:
regsvr32.exe sfFTPLib.dll

I think the proxy was not registered.

Regards,
Mat


Installed the latest and manually registered the sfFTPLib.dll. I am still not able to set the PrivateKey to the connection. Is it possible that the PrivateKey property is read only when used from the from "smartFTP.Application"?

#8 mb

mb

    Developer

  • Administrators
  • 11527 posts
  • Gender:
    Male
  • Location:
    Worldwide

Posted 22 September 2008 - 08:13 PM

I created the following .wsf script and it didn't throw any errors:

<?xml version="1.0"?>
<package>
<job>
<reference object="SmartFTP.Application" />
<reference object="sfFTPLib.SFTPConnection" />

<script language="VBScript">

<![CDATA[

Option Explicit

Dim objSmartFTP
'Set objSmartFTP = WScript.CreateObject("SmartFTP.Application")
Set objSmartFTP = GetObject(,"SmartFTP.Application")

Dim objFTP
Set objFTP = objSmartFTP.CreateObject("sfFTPLib.SFTPConnection")
Dim objKeyManager
Set objKeyManager = objSmartFTP.CreateObject("sfFTPLib.KeyManager")

Dim objKey
Set objKey = objKeyManager.LoadFile("C:\PrivateKey", "")

objFTP.PrivateKey = objKey

WScript.Echo("Done")

]]>
</script>
</job>
</package>


#9 Mathewscw

Mathewscw
  • Members
  • 5 posts

Posted 22 September 2008 - 08:57 PM

I created the following .wsf script and it didn't throw any errors:

<?xml version="1.0"?>
<package>
<job>
<reference object="SmartFTP.Application" />
<reference object="sfFTPLib.SFTPConnection" />

<script language="VBScript">

<![CDATA[

Option Explicit

Dim objSmartFTP
'Set objSmartFTP = WScript.CreateObject("SmartFTP.Application")
Set objSmartFTP = GetObject(,"SmartFTP.Application")

Dim objFTP
Set objFTP = objSmartFTP.CreateObject("sfFTPLib.SFTPConnection")
Dim objKeyManager
Set objKeyManager = objSmartFTP.CreateObject("sfFTPLib.KeyManager")

Dim objKey
Set objKey = objKeyManager.LoadFile("C:\PrivateKey", "")

objFTP.PrivateKey = objKey

WScript.Echo("Done")

]]>
</script>
</job>
</package>



Thanks, it is working now. I feel a little dumb, was using CreateObject instead of GetObject.

#10 mb

mb

    Developer

  • Administrators
  • 11527 posts
  • Gender:
    Male
  • Location:
    Worldwide

Posted 22 September 2008 - 09:06 PM

Both ways should be working.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users