cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: HTTPS + Certificate

From: Valter Santos - Webmaster <webmaster_at_vnsantos.com>
Date: Tue, 23 Sep 2003 17:54:49 +0100

See in the phpinfo() if there are two lines that say:

      CURL support enabled
      CURL Information libcurl/7.10.4 zlib/1.1.4 (at list this version)

If not, your server doesn't configured to run CURL function width SSL.

Another thing:
try this similar code just for testing the comunication:

  curl_setopt ($ch, CURLOPT_URL, $url_address);
  curl_setopt ($ch, CURLOPT_POST, 1);
  curl_setopt ($ch, CURLOPT_POSTFIELDS, $request);
  curl_setopt ($ch, CURLOPT_POSTFIELDSIZE, 1);
  curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
  curl_setopt ($ch, CURLOPT_HEADER, 0);
  curl_setopt ($ch, CURLOPT_SSLVERSION, 3);
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_SSLCERT, $cert);
  curl_setopt ($ch, SSLCERTPASSWD, $pwd);

// $request is the information you are send to be returned
// $cert - path and filename of certificate

How do you have converted your SSL certificate to pem format? This is
important!
see: http://www.pubcookie.org/docs/install-filter-3.0.html

Regards,
Valter Santos

----- Original Message -----
From: "Frédéric Dufour" <fdufour_at_logfi.fr>
To: <curl-and-php_at_lists.sourceforge.net>
Sent: Tuesday, September 23, 2003 3:03 PM
Subject: HTTPS + Certificate

> Hello,
>
> I want to convert cURL command line into PHP program.
>
> My cURL command line is :
>
> curl --cacert CAROOT.pem --cert MYCERT.pem --key MYKEY.pem
> https://thewebsite/
>
> the result of this command line is ok : I have the right page.
>
> I try to transform this command line in PHP :
>
> $website = "https://thewebsite/";
> $url = $website.$_SERVER["PATH_INFO"];
> $MyCert = "MYCERT.pem"; // my private certificate
> $keyfile = "MYKEY.pem"; // your private key file
> $certroot = "CAROOT.pem"; // root certificate
> $certsite = "CAHOMO.pem"; // website certificate
> $passwd = "0b14b67f"; // my password string
> $file = "./result.html";
>
> $ch = curl_init ($url);
> $fp = fopen ($file, "w") or die("Unable to open $file for writing.\n");
> if (!$ch) {
> die ("Couldn't Initialize cURL handle\n");
> }
>
>
> $code = curl_exec ($ch);
>
> if ($code != CURLE_OK) {
> die ("cURL error: " . curl_error ($ch) . "\n");
> }
>
> echo "<pre>";
> print_r(curl_getinfo($ch));
> echo "\n\ncURL error number:" .curl_errno($ch);
> echo "\n\ncURL error:" . curl_error($ch);
> echo "</pre>";
> curl_close ($ch);
> fclose ($fp);
>
> ?>
>
> the result is :
>
> Array
> (
> [url] => https://thewebsite/
> [http_code] => 0
> [header_size] => 0
> [request_size] => 0
> [filetime] => -1
> [ssl_verify_result] => 0
> [redirect_count] => 0
> [total_time] => 0
> [namelookup_time] => 0.013
> [connect_time] => 0.037
> [pretransfer_time] => 0
> [size_upload] => 0
> [size_download] => 0
> [speed_download] => 0
> [speed_upload] => 0
> [download_content_length] => 0
> [upload_content_length] => 0
> [starttransfer_time] => 0
> [redirect_time] => 0
> )
>
> cURL error number:58
>
> cURL error:unable to set certificate file (wrong password?)
>
>
> Someone can help me, i don't see where is my error... :-(
>
> Thank you for your answer !
>
> --
> Frédéric
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
>

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-09-23