Tim Duncklee | 1 Jul 2008 04:18

Curl refuses to configure with ssl

Running Fedora8 with openssl-0.9.8h and curl-7.18.2 I do:
./configure --with-ssl

I've tried every variation I can think of but I always end up with:
SSL support:     no

I see the check with pkg-config fails but openssl IS installed and working
with apache.

...
checking for pkg-config... /usr/bin/pkg-config
checking OpenSSL options with pkg-config... no
checking for gdi32... no
checking for CRYPTO_lock in -lcrypto... no
checking for CRYPTO_add_lock in -lcrypto... no
checking for inflateEnd in -lz... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
configure: found both libz and libz.h header
checking for libssh2_channel_open_ex in -lssh2... yes
checking libssh2.h usability... yes
checking libssh2.h presence... yes
checking for libssh2.h... yes
configure: WARNING: SSL disabled, you will not be able to use HTTPS, FTPS,
NTLM and more.
configure: WARNING: Use --with-ssl, --with-gnutls or --with-nss to address
this.
...

(Continue reading)

Pragya Ratna Bajracharya | 1 Jul 2008 05:24
Picon

Re: configuring curl with proxy servers

I updated the below code to the following:
<?php
$ch = curl_init();
curl_setopt ($ch, CURLOPT_PROXY, "xx.xxx.xx.xx:8080");
curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, 0);  
curl_setopt($ch,CURLOPT_VERBOSE,true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_COOKIEJAR,"cookie.txt");
curl_setopt($ch,CURLOPT_COOKIEFILE,1);
curl_setopt($ch, CURLOPT_URL,"http://www.example.com");
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
var_dump($info);
echo $response;
?>

the curl info shows the following details:
array
  'url' => string 'http://www.example.com' (length=32)
  'http_code' => int 0
  'header_size' => int 0
  'request_size' => int 0
  'filetime' => int -1
  'ssl_verify_result' => int 0
  'redirect_count' => int 0
  'total_time' => float 0
  'namelookup_time' => float 0
  'connect_time' => float 0
  'pretransfer_time' => float 0
  'size_upload' => float 0
  'size_download' => float 0
  'speed_download' => float 0
  'speed_upload' => float 0
  'download_content_length' => float 0
  'upload_content_length' => float 0
  'starttransfer_time' => float 0
  'redirect_time' => float 0

however the response is still not being available.

2008/6/30 haroon ahmad <haroon <at> fastcreators.com>:
Have you dont http sniffing to see if the proxy works like this on itself? it might use some session/cookie that you will have to pass in cURL session to successfully use proxy.

Regards,
Haroon Ahmad
Expert Offshore Web Developer

2008/6/30 Pragya Ratna Bajracharya <pragyabchar <at> gmail.com>:
Hello all,

Based on this following example

<?

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://www.example.com');

curl_setopt($ch, CURLOPT_HEADER, 1);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);

curl_setopt($ch, CURLOPT_PROXY, 'fakeproxy.com:1080');

curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:password');

$data = curl_exec();

curl_close($ch);

 ?>
I changed the value of the proxy url and proxy port to my own data.

When i try to run the above script, it returns false on the $data. Is there some special configurations to be done on the server?

I am using PHP Version 4.4.8 and the curl installed on the server is libcurl/7.16.0 OpenSSL/0.9.7m zlib/1.2.3.
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php



_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php


_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Daniel Stenberg | 1 Jul 2008 11:06
Picon
Favicon
Gravatar

Re: Curl refuses to configure with ssl

On Mon, 30 Jun 2008, Tim Duncklee wrote:

> Running Fedora8 with openssl-0.9.8h and curl-7.18.2 I do:
> ./configure --with-ssl

It would probably make more sense to talk about curl's configure on the 
curl-users list.

> I see the check with pkg-config fails but openssl IS installed and working 
> with apache.

Right, but since we don't know how apache finds and uses it that info doesn't 
help us much.

> checking for pkg-config... /usr/bin/pkg-config
> checking OpenSSL options with pkg-config... no
> checking for CRYPTO_lock in -lcrypto... no

So where is OpenSSL installed on your machine? Did you try specifying the root 
prefix with the --with-ssl option?

--

-- 

  / daniel.haxx.se
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

David Yamanoha | 2 Jul 2008 03:02
Picon
Favicon

Posting multiple values for a single key

How do you go about configuring curl to allow for posing multiple values for a single key? i.e.

...
curl_addPostData($curl, CURLOPT_POSTFIELDS, 'CategoryChoice[]', 0 );
curl_addPostData($curl, CURLOPT_POSTFIELDS, 'CategoryChoice[]', 12 );
curl_addPostData($curl, CURLOPT_POSTFIELDS, 'CategoryChoice[]', 14 );
curl_exec($curl);

// How do you 'curl_addPostData'??
...


Making the world a better place one message at a time. Check out the i'm Talkathon.
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Daniel Stenberg | 2 Jul 2008 10:18
Picon
Favicon
Gravatar

Re: Posting multiple values for a single key

On Tue, 1 Jul 2008, David Yamanoha wrote:

> How do you go about configuring curl to allow for posing multiple values for 
> a single key? i.e.

As usual, trace a "live" post with LiveHTTPHeaders to see what it makes your 
browser send, then you repeat that with PHP/CURL.

--

-- 

  / daniel.haxx.se
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

David Shields | 2 Jul 2008 14:07

Problems thru a proxy.


I'm not a curl expert, but I thought I knew what I was doing ! Source is at
end of this post.
I am trying to make my app look like a browser to get a http request to an
outside site (sending SMS messages). App is in php on a local server.
Problem is local network is within an education authority, and all access
to internet is thru their proxy server (filters and does all sorts of
stuff.)

The proxy is a bit weird, so I've been using Fiddler to debug the traffic
from a browser and from my app to see difference (because the proxy is
blocking me with 403 Forbidden, so I'm guessing I'm not being a browser
correctly).

But: when using Fiddler(to debug the HTTP conversation), there is a
difference in the conversation between my app and the target site, and a
browser and the target site.

Picture is like this:

Browser <--->Fiddler Proxying 127.0.0.1:8888 <---Real proxy:80 --->
www.google.co.uk
My APP <--->Fiddler Proxying 127.0.0.1:8888 <---Real proxy:80 --->
www.google.co.uk

Browser conversation goes like this: 
------------------------------------
Connection 1: 
GET / HTTP/1.1
Host: www.google.co.uk
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9)
Gecko/2008052906 Firefox/3.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Proxy-Connection: keep-alive
Cookie:
PREF=ID=09d7d0513a2af2a7:TM=1214992131:LM=1214992131:S=AS1YPHde9fVL6i3D;
NID=12=B98NJ2rNDeUzjBxixRIbSVGjIZGXSFbG_llKPHF3FnwyB5uSJqBgVkwFCRw3nk1JvpV_q37nfFe960az37YZabzJQ_jBjR4fg9bLm8x4U0XJK9flYY00b2wMMnxSieki

receives 302 redirect : 
HTTP/1.0 302 Moved Temporarily
Server: squid/2.5.STABLE12
Date: Wed, 02 Jul 2008 11:48:01 GMT
Content-Length: 0
Location:
http://securelogin.leedslearning.net/dpid=1&cat=101&ttl=0&groupname=-&policyname=-&username=-&userip=10.6.3.20&connectionip=10.253.21.61&nsphostname=lln-civ-nsp-02.leedslearning.net&protocol=squid25&dplanguage=-&url=aHR0cDovL3d3dy5nb29nbGUuY28udWsv

then a number of redirects to https, and then a proxy login page (which is
what I was hping to get)

My App conversation goes like this: 
-----------------------------------
CONNECT www.google.co.uk:80 HTTP/1.0
Host: www.google.co.uk:80
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
InfoPath.1; .NET CLR 2.0.50727)
Accept: */*
Accept-Language: en-gb
Accept-Encoding: gzip, deflate
Proxy-Connection: Keep-Alive
Cookie:
PREF=ID=7c5d00a43b1c1c23:TM=1214992129:LM=1214992129:S=Xtw0zCpIwJa-MjnA

note the CONNECT request through tunnel, rather than the GET as with the
browser.

The curl error is "56 Received HTTP code 403 from proxy after CONNECT"

and the result of the verbose STDERR logging is 
* About to connect() to proxy 127.0.0.1 port 8888 (#0)
*   Trying 127.0.0.1... * connected
* Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0)
* Establish HTTP proxy tunnel to www.google.co.uk:80
> CONNECT www.google.co.uk:80 HTTP/1.0
Host: www.google.co.uk:80
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
InfoPath.1; .NET CLR 2.0.50727)
Accept: */*
Accept-Language: en-gb
Accept-Encoding: gzip, deflate
Proxy-Connection: Keep-Alive
Cookie:
PREF=ID=7c5d00a43b1c1c23:TM=1214992129:LM=1214992129:S=Xtw0zCpIwJa-MjnA

< HTTP/1.0 403 Forbidden
< Server: squid/2.5.STABLE12
< Mime-Version: 1.0
< Date: Wed, 02 Jul 2008 11:50:33 GMT
< Content-Type: text/html
< Content-Length: 1096
< Expires: Wed, 02 Jul 2008 11:50:33 GMT
< X-Squid-Error: ERR_ACCESS_DENIED 0
< X-Cache: MISS from lln-spp-nc-03.leedslearning.net
< Proxy-Connection: keep-alive
< 
* Received HTTP code 403 from proxy after CONNECT
* Closing connection #0

Why is my app doing a CONNECT, and the browser doing a GET www.google.co.uk
? 
How can I set up curl to emulate the browser conversation ? 

Note - it's not a browser (IE) funny - fiddler binds into IE, but the
browser conversation above is Firefox, installed clean on the machine and
proxy set to 127.0.0.1:8888

Hope someone can shed some light on this, I'm pulling my hair out.
David

Source code for php test is : 
$fp=fopen('stderr.txt', 'w');
$headers = array(
		"Accept: */*",
		"Accept-Language: en-gb",
		"Accept-Encoding: gzip, deflate",
		"Proxy-Connection: Keep-Alive",
		"Cookie:
PREF=ID=7c5d00a43b1c1c23:TM=1214992129:LM=1214992129:S=Xtw0zCpIwJa-MjnA",
		);
$agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1;
.NET CLR 2.0.50727)";
$ch=curl_init();
$r=curl_setopt($ch, CURLOPT_URL, "http://www.google.co.uk");
$r=curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$r=curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$r=curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$r=curl_setopt($ch, CURLOPT_USERAGENT, $agent);
$r=curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

$r=curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
$r=curl_setopt($ch, CURLOPT_PROXYPORT, 8888);
$r=curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1');

$r=curl_setopt($ch, CURLOPT_VERBOSE, 1);
$r=curl_setopt($ch, CURLOPT_STDERR, $fp);

$data=curl_exec($ch);
$e=curl_errno($ch).' '.curl_error($ch);

curl_close($ch);

fclose($fp);

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

Daniel Stenberg | 2 Jul 2008 21:57
Picon
Favicon
Gravatar

Re: Problems thru a proxy.

On Wed, 2 Jul 2008, David Shields wrote:

> My App conversation goes like this:
> -----------------------------------
> CONNECT www.google.co.uk:80 HTTP/1.0

> note the CONNECT request through tunnel, rather than the GET as with the
> browser.
>
> The curl error is "56 Received HTTP code 403 from proxy after CONNECT"

Yes, most proxies are setup to refuse CONNECT to other ports than 443.

> Why is my app doing a CONNECT, and the browser doing a GET www.google.co.uk
> ?

> $r=curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);

Because you asked for CURLOPT_HTTPPROXYTUNNEL.

--

-- 

  / daniel.haxx.se
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

David Yamanoha | 3 Jul 2008 20:03
Picon
Favicon

RE: Posting multiple values for a single key

I did.  PhP provides a mechanism through posting, such that if you provide multiple inputs with the same name, followed by array notation, i.e. category[], category[], category[], you will receive the POST in an array, where category[0] ... category[2] contains the the values you input.  As far as I know, doing this through cURL is not an option.  If you have an associative array, you can only associate one key value per key.  I'm not sure why there aren't any other documented cases of people having problems with this... unless there's a simple solution to the problem.

So to clarify, the post data literally is looked something like this:

username : Me
password : lateda
categoryChoice[] : 232234
categoryChoice[] : 12
cateogryChoice[] : random string
acceptTOS: true




Windows Live Hotmail is giving away Zunes. Enter for your chance to win. Enter Now!
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Daniel Stenberg | 3 Jul 2008 22:36
Picon
Favicon
Gravatar

RE: Posting multiple values for a single key

On Thu, 3 Jul 2008, David Yamanoha wrote:

> I did.  PhP provides a mechanism through posting, such that if you provide 
> multiple inputs with the same name, followed by array notation, i.e. 
> category[], category[], category[], you will receive the POST in an array, 
> where category[0] ... category[2] contains the the values you input.  As far 
> as I know, doing this through cURL is not an option.

I think you're wrong, at least for "normal" posts. Although I don't know much 
about PHP and the PHP/CURL binding does have more restrictions than libcurl 
itself does.

> If you have an associative array, you can only associate one key value per 
> key.

Yes, and that's one of the primary reasons I dislike the way PHP/CURL supports 
multipart formposts. The second reason on my list would be that you cannot 
specify in which order they go in the data.

> I'm not sure why there aren't any other documented cases of people having 
> problems with this... unless there's a simple solution to the problem.
>
> So to clarify, the post data literally is looked something like this:
>
> username : Me
> password : lateda
> categoryChoice[] : 232234
> categoryChoice[] : 12
> cateogryChoice[] : random string
> acceptTOS: true

But this is posted as a normal POST, isn't it? You don't need nor want the 
associative array then but you specify your data like this:

"username=me&password=lateda&categoryChoice[]=232234&categoryChoice[]=12&cateogryChoice[]=random%20string&acceptTOS=true"

Possibly the [] need to be %5B%5d instead. LiveHTTPHeaders would show...

--

-- 

  / daniel.haxx.se
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

David Yamanoha | 3 Jul 2008 23:00
Picon
Favicon

RE: Posting multiple values for a single key

> But this is posted as a normal POST, isn't it? You don't need nor want the
> associative array then but you specify your data like this:
>
> "username=me&password=lateda&categoryChoice[]=232234&categoryChoice[]=12&cateogryChoice[]=random%20string&acceptTOS=true"

I tried doing it via a query string.  However in my case there are three image fields, along with the above, and you can't post the 'data/oct-stream or whatever it is' via a querry string...

So the real problem is, multiple values per single key, AND image data all being posted through the same form.



Do more with your photos with Windows Live Photo Gallery. Get Windows Live-Free
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

Gmane