cURL / Mailing Lists / curl-library / Single Mail

curl-library

Problem with FTP SSL

From: Михаил Шогин <shogin_m_at_mail.ru>
Date: Mon, 24 Oct 2005 14:35:34 +0400

Hi.

I want to use libcurl in my app.
I need:
1) connect to FTP SLL
2) get list of files
3) download or upload file

I find somples for perl and make in for c++, but it don't work.

<CODE>

struct FtpFile {
  char *filename;
  FILE *stream;
};

int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
{
  struct FtpFile *out=(struct FtpFile *)stream;
  if(out && !out->stream) {
    /* open file for writing */
    out->stream=fopen(out->filename, "wb");
    if(!out->stream)
      return -1; /* failure, can't open file to write */
  }
  return fwrite(buffer, size, nmemb, out->stream);
}

int main(void)
{
  CURL *curl;
  CURLcode res;
  struct FtpFile ftpfile={
    "test", /* name to store the file as if succesful */
    NULL
  };

  curl = curl_easy_init();
  if(curl) {
            curl_easy_setopt(curl, CURLOPT_USERPWD,"test:12qw");

                curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30 );

                curl_easy_setopt(curl, CURLOPT_URL, "ftp://192.168.11.32:990/test.pl" );

                curl_easy_setopt(curl, CURLOPT_FTP_SSL, CURLFTPSSL_TRY);

                curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);

                curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, FALSE);

                curl_easy_setopt(curl, CURLOPT_SSLVERSION,2 );

         // curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite );

                
                //curl_easy_setopt(curl, CURLOPT_FILE, &ftpfile);

            curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE);

                res= curl_easy_perform(curl);
    }

  if(ftpfile.stream)
    fclose(ftpfile.stream); /* close the local file */

  curl_global_cleanup();

  return 0;
}

</CODE>

I use Serv-U with Allow only SSL/TLS sessions.

Can you help me?

Michael
Received on 2005-10-24