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

curl-and-php

Re: using curl in PHP

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 23 Oct 2001 13:26:41 +0200 (MET DST)

On Tue, 23 Oct 2001, Hugo Alexandre A. S. Dias wrote:

I've CC'ed this reply to the curl and php mailing list, which is dedicated to
issues such as yours.

> My problem is like this. I need to make a post to a https server and i
> need to send a certificate to verify my identity.
>
> This is the code i'm using:
> <?
> $ch=curl_init("$url");
> curl_setopt($ch,CURLOPT_VERBOSE,1);
> curl_setopt($ch, CURLOPT_FAILONERROR, 1);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch, CURLOPT_TIMEOUT, 3);
> curl_setopt($ch,CURLOPT_SSLCERT,"multicert.pem");
> curl_setopt($ch,CURLOPT_SSLCERTPASSWD,"3I3I37RP52G1L15D8T8S");
> curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
> curl_setopt($ch, CURLOPT_POST, 1);
> curl_setopt($ch, CURLOPT_POSTFIELDS, "$params");
> curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
>
> $data = curl_exec($ch);
> echo "<p>$data</p>";
>
> $info=curl_getinfo($ch);
> while(list($key,$value)=each($info))
> echo "<p>$key=$value</p>";
>
> curl_close($ch);
> ?>
>
> But i can't connect to the server. Or i don't get an answer from it, but
> when i put the address in the browser it works just fine. can you tell me
> where's my mistake?

A timeout on 3 seconds seems exceedingly strict.

Is the path to the certificate file properly specified? Is the certificate
file both the public key and certs parts in one file?

What does the verbose output show?

> I'm using PHP 4.0.6 + IIS5.

I recall seeing people express problems with PHP 4.0.6 and curl with SSL. But
don't quote me on that, I'm not sure.

What version of curl is this?

> I have the curl shell utility too and no results with it.

You could start with the shell tool to get a working command line first, and
then when that works you could translate it over to PHP. It might be an
easier way to work.

Use the -v flag for verbose output. What happens when you use that?

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2001-10-23