Argument List Too Long Libcurl C Program Error

- 1 answer

I am using a C program to connect to an ftp server and upload a file. Previously the server was not using SSL and I was able to do the file upload using the following code :


curl = curl_easy_init();


    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, throw_away);

    curl_easy_setopt(curl, CURLOPT_USERNAME, "username");
    curl_easy_setopt(curl, CURLOPT_PASSWORD, "password");

    if (CURLE_OK != (res = curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftpb.****.com")))
        printf("Failed to check ftp url, Error : %s : %d\n", curl_easy_strerror(res), res);
    curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);

    // Connection establishment timeout
    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 20);
    printf("Trying to connect...\n");
    if (CURLE_OK != (res = curl_easy_perform(curl)))
        /* If fail to connect */
        printf("FTP connection failed...%s : %d\n", strerror(res), res);
        /* If connected succesfully */
        printf("Connected to FTP successfully...\n");

      /****** proceed with upload ******/

After the ftp server switched to use SSL certification, I added the following line to my code to use SSL:

    curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);

Now, when I run the program, my application fails to connect to FTP and show the message :

"FTP connection failed...Argument list too long : 7"

The same error is obtained even if I do not add the CURLOPT_USE_SSL part.

I am able to connect to the ftp server using Filezilla (only if I add ftps to the address). Adding ftps in my code gives the error:

"FTP connection failed...Device not a stream : 60"

Anybody knows a workaround for this?



I was able to fix the issue by adding the line

curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);

The application does not try to validate the SSL certificates now and proceeds with the connection