curl-and-php
Re: HTTPS + Certificate
Date: Wed, 24 Sep 2003 09:18:32 -0400
See my comments and questions below.
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 am looking at the command line documentation at http://curl.haxx.se/docs/manpage.html and I do not see a --key option anywhere. The only place the word "key" appears on that page is in the description of --cert: "Note that this certificate is the private key and the private certificate concatenated!" How did you learn of the --key option? Does your certificate file have both your private key and private certificate as described in the documentation?
>
> 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);
In my PHP 4.3.2 docs, I do not see CURLOPT_SSLKEY and CURLOPT_SSLKEYPASSWD. I do see CURLOPT_SSLCERT and an associated CURLOPT_SSLCERTPASSWD. How did you learn of CURLOPT_SSLKEY and CURLOPT_SSLKEYPASSWD? Are you attempting to use options that have been abandoned in more recent versions?
Scott Nichol
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-09-24