cURL / Mailing Lists / curl-library / Single Mail

curl-library

Reflection for Secure IT Server

From: Xu, Qiang (FXSGSC) <Qiang.Xu_at_fujixerox.com>
Date: Mon, 3 May 2010 17:26:12 +0800

Hi, list:

Recently, I am hit with a problem of transfer to Reflection for Secure IT Server, which provides SFTP service (http://www.attachmate.com/Products/mft/Security/rist-winserver/tech-specs-win-server.htm).

libssh2 itself seems innocent:
=============================================
qxu_at_durian(pts/3):~/opensrc/libssh2-1.2.4/example[236]$ ./sftp_write 13.121.8.133 <user> <pass> test.pdf /Home/Scans/test.pdf
Fingerprint: 7B 98 19 12 F3 A2 14 93 3F 72 85 3C 43 DA 19 EF 7F 9A 3A 6B
libssh2_sftp_init()!
libssh2_sftp_open()!
libssh2_sftp_open() is done, now send data!
all done
=============================================
The file in the remote server is identical to the local one. Good job.

However, libcurl doesn't work with the server:
=============================================
/* sample source code */
#include <stdio.h>
#include <sys/stat.h>
#include <curl/curl.h>

int main(int argc, char *argv[])
{
  CURLcode ret;
  CURL *hnd = curl_easy_init();
  char *localName = "./testSmall.pdf";
  FILE *localFile = NULL;
  struct stat localFileInfo = {0};

  curl_easy_setopt(hnd, CURLOPT_URL, "sftp://13.121.8.133/Home/Scans/testSmall.pdf");
  curl_easy_setopt(hnd, CURLOPT_USERPWD, "<user>:<pass>");
  curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1);
  curl_easy_setopt(hnd, CURLOPT_UPLOAD, 1);

  if ((localFile = fopen(localName, "r")) != NULL &&
      stat(localName, &localFileInfo) == 0)
  {
      curl_easy_setopt(hnd, CURLOPT_READDATA, localFile);
      curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, (curl_off_t)localFileInfo.st_size);
      printf("local file size is [%d] bytes\n", (long)localFileInfo.st_size);
  }
  else
  {
      printf("either cannot open local file [%s] or cannot get its size", localName);
      return 1;
  }

  ret = curl_easy_perform(hnd);

  curl_easy_cleanup(hnd);
  return (int)ret;
}

/* result */
qxu_at_durian(pts/1):~/opensrc/curl-7.20.1/example[222]$ ./sftp_reflection
local file size is [523340] bytes
* About to connect() to 13.121.8.133 port 22 (#0)
* Trying 13.121.8.133... * connected
* Connected to 13.121.8.133 (13.121.8.133) port 22 (#0)
* SSH authentication methods available: password
* Initialized password authentication
* Authentication complete
=============================================
You can see it hangs there and never finishes after authentication is passed. The file size transferred to the remote server is only 16KB, while the local one is 523,340 bytes. Even VERBOSE flag is set, I still can't get more output info. By the way, is there anything to be suspected in my sample code?

I wanted to use the command-line to do a double check, but it got worse:
=============================================
xu@durian(pts/1):~/opensrc/curl-7.20.1/src[227]$ ./curl -v -u <user>:<pass> -T testSmall.pdf sftp://13.121.8.133/Home/Scans/testSmall.pdf
* About to connect() to 13.121.8.133 port 22 (#0)
* Trying 13.121.8.133... % Total % Received % Xferd Average Speed Time
    Time Time Current
                                 Dload Upload Total Spent Left Speed
  0 0 0 0 0 0 0 0 --:--:-- 0:00:21 --:--:-- 0co
nnected
* Connected to 13.121.8.133 (13.121.8.133) port 22 (#0)
* Failed to read known hosts from /home/qxu/.ssh/known_hosts
* SSH host check: 2, key: <none>
* Closing connection #0
* SSL peer certificate or SSH remote key was not OK

curl: (51) SSL peer certificate or SSH remote key was not OK
=============================================
It just does not go on to do password authentication after failing to read the file "known_hosts".

Any help?

Thanks,
Xu Qiang
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-05-03