cURL / Mailing Lists / curl-library / Single Mail

curl-library

[ curl-Bugs-921826 ] A program for accessing https pages runs on Linux

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Tue, 23 Mar 2004 08:09:13 -0800

Bugs item #921826, was opened at 2004-03-23 08:09
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=921826&group_id=976

Category: libcurl
Group: crash
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Daniel Stenberg (bagder)
Summary: A program for accessing https pages runs on Linux

Initial Comment:
but crashes on Windows. Because I&#039;m very new to it, it
might be me misusing the library.
The point is I can access the page with either curl on
Windows or Linux but can not access the page with
libcurl under Windows.

- I have made my own server certificate and my own
personal certificat for accessing the pages.

Here&#039;s the code:
#include <stdio.h>
#include <curl/curl.h>

static int fetch_page (CURL *curl){
        CURLcode res;
        char err_buf [2* CURL_ERROR_SIZE];
        char url [] = "https://qss-sec/libcurl-
examples/simple.txt";
    char *dump_file_name = "https_dump_file.txt";
        char *priv_key_name = "toolbox.pem";
        char *ca_bundle_file = "curl-ca-bundle.crt";

        FILE *dump_file = fopen (dump_file_name, "w");
    if (NULL == dump_file) {
      return 0;
    }
    res = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER,
err_buf);
        if (CURLE_OK != res){
                goto error;
        }
        res = curl_easy_setopt(curl,
CURLOPT_VERBOSE);
    
    res = curl_easy_setopt
(curl,CURLOPT_SSLKEY,priv_key_name);
    if (CURLE_OK != res){
      goto error;
    }
    
    res = curl_easy_setopt(curl,
CURLOPT_SSLKEYPASSWD, "toolbox");
    if (CURLE_OK != res){
      goto error;
    }
        res = curl_easy_setopt(curl, CURLOPT_CAINFO,
ca_bundle_file);

        res = curl_easy_setopt(curl, CURLOPT_URL,
url);
        if (CURLE_OK != res){
                goto error;
        }
        res = curl_easy_setopt(curl,
CURLOPT_WRITEDATA, dump_file);
        if (CURLE_OK != res){
                goto error;
        }
        
    
        res = curl_easy_perform(curl);
        if (CURLE_OK != res){
                goto error;
        }
    if (NULL != dump_file){
      fclose(dump_file);
    }
    return 1;
        error:
                fprintf(stderr, "curl error: %s\n",
err_buf);
        if (NULL != dump_file) fclose (dump_file);
                return 0;

}

int main(void)
{
  int irval = 0;
  CURL *curl = curl_easy_init();

  if(NULL != curl) {
    irval = fetch_page(curl);
    if (irval) {
                puts("Fetching of page successfull");
        }
        curl_easy_cleanup(curl);
  }
  curl_global_cleanup();
  return 0;
}
The output is as follows:
H:\Arbeit\Toolbox\libcurl\src\https_access\Debug>https_
access
* About to connect() to qss-sec port 443
* Connected to qss-sec (192.168.1.15) port 443
* successfully set certificate verify locations:
* CAfile: curl-ca-bundle.crt
  CApath: none
* SSL connection using DHE-RSA-AES256-SHA
* Server certificate:
*
subject: /C=DE/ST=BW/L=Heidelsheim/O=QSS/CN=qss-
sec
* start date: 2004-03-22 16:46:02 GMT
* expire date: 2005-03-22 16:46:02 GMT
* common name: qss-sec (matched)
* issuer: /C=DE/ST=BW/L=Heidelsheim/O=QSS
* SSL certificate verify ok.
> GET /libcurl-examples/simple.txt HTTP/1.1
Host: qss-sec
Pragma: no-cache
Accept: */*

< HTTP/1.1 200 OK
< Date: Tue, 23 Mar 2004 16:07:15 GMT
< Server: Apache/2.0.48 (Debian GNU/Linux) PHP/4.3.4
mod_ssl/2.0.48 OpenSSL/0.9.7c
< Last-Modified: Mon, 22 Mar 2004 14:36:35 GMT
< ETag: "14c3a-28-396c22c0"
< Accept-Ranges: bytes
< Content-Length: 40
< Content-Type: text/plain; charset=ISO-8859-1

Doing the same with the command line tool I got this:
H:\Arbeit\Toolbox\libcurl\src\https_access\Debug>curl -
v "https://qss-sec/libcurl-examples/simple.tx
t"
* About to connect() to qss-sec:443
* Connected to qss-sec (192.168.1.15) port 443
* successfully set certificate verify locations:
* CAfile: /usr/share/curl/curl-ca-bundle.crt
* CApath: none
* SSL connection using DHE-RSA-AES256-SHA
* Server certificate:
*
subject: /C=DE/ST=BW/L=Heidelsheim/O=QSS/CN=qss-
sec
* start date: 2004-03-22 16:46:02 GMT
* expire date: 2005-03-22 16:46:02 GMT
* common name: qss-sec (matched)
* issuer: /C=DE/ST=BW/L=Heidelsheim/O=QSS
* SSL certificate verify ok.
> GET /libcurl-examples/simple.txt HTTP/1.1
User-Agent: curl/7.10.8 (i686-pc-cygwin) libcurl/7.10.8
OpenSSL/0.9.7c zlib/1.2.1
Host: qss-sec
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg,
image/pjpeg, */*

< HTTP/1.1 200 OK
< Date: Tue, 23 Mar 2004 16:08:25 GMT
< Server: Apache/2.0.48 (Debian GNU/Linux) PHP/4.3.4
mod_ssl/2.0.48 OpenSSL/0.9.7c
< Last-Modified: Mon, 22 Mar 2004 14:36:35 GMT
< ETag: "14c3a-28-396c22c0"
< Accept-Ranges: bytes
< Content-Length: 40
< Content-Type: text/plain; charset=ISO-8859-1
Eine HTTPS Seite, streng öffentlich ;-)
* Connection #0 left intact
* Closing connection #0

H:\Arbeit\Toolbox\libcurl\src\https_access\Debug>

On Linux do I get the output and the dumped file.
The libcurl I use is 7.11.1 compiled with MSVC 7 and
openssl 0.97c ....

Hope someone can point me into the right direction.

Regards
Friedrich

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=921826&group_id=976
Received on 2004-03-23