curl-and-php
Re: HTTPS + Certificate
Date: Tue, 23 Sep 2003 10:25:12 -0400
> curl_setopt($ch, CURLOPT_CAINFO, $certsite);
From a quick look, I think this should be
curl_setopt($ch, CURLOPT_CAINFO, $certroot);
Whether there are other problems, I cannot say, as I have only used the basic SSL capabilities.
Scott Nichol
Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message -----
From: "Frédéric Dufour" <fdufour_at_logfi.fr>
To: <curl-and-php_at_lists.sourceforge.net>
Sent: Tuesday, September 23, 2003 10:03 AM
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");
> }
>
> curl_setopt ($ch, CURLOPT_FILE, $fp);
> curl_setopt($ch, CURLOPT_CAINFO, $certsite);
> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
> curl_setopt($ch, CURLOPT_SSLCERT, $MyCert);
> curl_setopt($ch, CURLOPT_SSLKEY, $keyfile);
> curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $passwd);
>
> $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