cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-users Mailing List Archives

Re: CURL return Values

From: John Vorwald <john_vorwald_at_msn.com>
Date: Mon, 11 Dec 2006 05:02:40 -0500

I have gotten a curl command line statement to work, but am unable to convert the command to libcurl to work in a C++ code.

Here's the command line statement that works.

curl --data-binary "VTI-GROUP=0&partId=_userid_&password=_passid_&acrover=7&fileDigit=A&Enter=Login" \
     --user-agent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0" \
     --referer https://tspweb2.tspsec.tsp.gov/login_at.htm<https://tspweb2.tspsec.tsp.gov/login_at.htm> \
     --output step4b.out \
     --trace-ascii step4b.trace \
     --dump-header step4b.hdr \
     "https://tspweb2.tspsec.tsp.gov/NASApp/tsp/authenticate.do?_name=nfclogin&SessionKey$=3ABC123<https://tspweb2.tspsec.tsp.gov/NASApp/tsp/authenticate.do?_name=nfclogin&SessionKey$=3ABC123>"

Here's my C++ code to implement the command line options

  CURL *curl;
  
  char *url("https://tspweb2.tspsec.tsp.gov/NASApp/tsp/authenticate.do?_name=nfclogin&SessionKey$=3ABC123<https://tspweb2.tspsec.tsp.gov/NASApp/tsp/authenticate.do?_name=nfclogin&SessionKey$=3ABC123>");
  char *body_file_name("tsp_login.txt");

  curl_global_init(CURL_GLOBAL_ALL);
  curl = curl_easy_init();
  if (curl) {

    curl_easy_setopt(curl, CURLOPT_USERAGENT,
                   "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0");
            
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
    curl_easy_setopt(curl, CURLOPT_POST, 1);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS,
                   "VTI-GROUP=0&partId=SSN&password=_password_&acrover=7&fileDigit=A&Enter=Login");
    curl_easy_setopt(curl, CURLOPT_REFERER, "https://tspweb2.tspsec.tsp.gov/login_at.htm<https://tspweb2.tspsec.tsp.gov/login_at.htm>");

    FILE *outfile = fopen(body_file_name, "wb");
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);

    curl_easy_setopt(curl, CURLOPT_URL, url);
    res = curl_easy_perform(curl);

    fclose(outfile);
 
    /* Cleanup before exit */
    curl_easy_cleanup(curl);
  }

Here's the output when running the C++ code

* About to connect() to tspweb2.tspsec.tsp.gov port 443
* Trying 38.118.64.250... * connected
* Connected to tspweb2.tspsec.tsp.gov (38.118.64.250) port 443
* SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

Suggestions on how to correct the C++ code. Seems to be a problem with the SSL certificate. Can I display the certificate file being used by libcurl. I used the default in the command line entry.

John
Received on 2006-12-11

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET