Michael Williams | 1 Sep 2006 03:56

Retrieving PHP results from another site with cookies in tact.

Hi all,

I'm not sure this is the proper list for this question, but I'm using  
cURL to retrieve PHP results from one server to another.  Basically  
the scenario is as follows:

1) www.companyname.com has a search mechanism that they want to allow  
partners to use.
2) the catch is that there is registration required.
3) once registered (and logged in) the user may then make use of the  
search capability to their heart's content

Obviously throwing up a quick and dirty frame is the *easiest*  
mechanism, but unfortunately it's not an option.  I'm currently using  
a Ajax (for the pretty effects) with a PROXY.PHP file on the  
"partner" sites.  This "proxy" file then handles communication  
between itself and the main server(s).  My question is, how is it  
possible to maintain a PHP session between two servers with a PHP  
script and cURL so that the partner server keeps the user "logged in"  
as if they were actually at the main server.

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

Tom Cannaerts | 2 Sep 2006 01:39
Picon

Curl + php + ssl = free() invalid pointer

Hi everyone,

 

I’m having this strange problem here.

 

I’m running a debian server with a 2.6 kernel.

I’ve installed PHP 5.1.6, Apache 2.2.2, Openssl 0.9.8b and libcurl3-dev_7.15.5-1

 

The problem occurs when I try to fetch a url using ssl from PHP, using the following code:

 

<?php

        $url = "https://someserver/somefile.ext";

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url);

        curl_setopt($ch, CURLOPT_HEADER, 0);

        curl_exec($ch);

        curl_close($ch);

?>

 

When I pull this file up in a browser, it works fine and prints the contents of the file specified.

However, when I call this file from the commandline, I get the following error:

 

*** glibc detected *** free(): invalid pointer: 0x40158640 ***

 

I already found out that the error occurs when calling curl_exec.

 

The strange thing is that when I run the php file from the command line, it gives me this error, but when I call the php file from a browser (through apache), it Works without a problems. If I simply run curl from the commandline, it works just fine. If I give a http:// instead of a https://, the everything works fine as well.

 

Does anyone know what might be wrong?

 

Kind regards,

 

Tom

 

 

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Kevin Carothers | 2 Sep 2006 02:05
Picon

Re: Curl + php + ssl = free() invalid pointer


On 9/1/06, Tom Cannaerts <curl <at> cakkie.be> wrote:

Hi everyone,

 

I'm having this strange problem here.


[---]


 Just searching the curl.haxx.se site it seems that there are some issues with glibc.   You might want to take a look around there. Sorry I couldn't be more help.

KC

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
santi wang | 2 Sep 2006 06:01
Picon
Favicon

Getting a copy of the CRT file using CURL

Hi All:
 
Does anyone know how to get a copy of the CRT file (SSL certificate inforation) using CURL in php?
 
Thanks,
 
Santi

Stay in the know. Pulse on the new Yahoo.com. Check it out.
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Daniel Stenberg | 2 Sep 2006 12:36
Picon
Favicon
Gravatar

Re: Curl + php + ssl = free() invalid pointer

On Sat, 2 Sep 2006, Tom Cannaerts wrote:

> When I pull this file up in a browser, it works fine and prints the contents 
> of the file specified.
>
> However, when I call this file from the commandline, I get the following 
> error:

Sounds like this PHP bug to me:

 	http://bugs.php.net/bug.php?id=38686

--

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

Tom Cannaerts | 2 Sep 2006 12:47
Picon

RE: Curl + php + ssl = free() invalid pointer

Well, I submitted that bug yesterday, after doing some more searching. From
what I've read, usually this error has got something to do with the way the
program calls curl, so I decided to submit it to PHP as well.

The latest snapshot doesn't fix the problem.

Tom

-----Oorspronkelijk bericht-----
Van: Daniel Stenberg [mailto:daniel <at> haxx.se] 
Verzonden: zaterdag 2 september 2006 12:37
Aan: curl with PHP
Onderwerp: Re: Curl + php + ssl = free() invalid pointer

On Sat, 2 Sep 2006, Tom Cannaerts wrote:

> When I pull this file up in a browser, it works fine and prints the
contents 
> of the file specified.
>
> However, when I call this file from the commandline, I get the following 
> error:

Sounds like this PHP bug to me:

 	http://bugs.php.net/bug.php?id=38686

--

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

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

Daniel Stenberg | 2 Sep 2006 12:53
Picon
Favicon
Gravatar

RE: Curl + php + ssl = free() invalid pointer

On Sat, 2 Sep 2006, Tom Cannaerts wrote:

> Well, I submitted that bug yesterday, after doing some more searching. From 
> what I've read, usually this error has got something to do with the way the 
> program calls curl, so I decided to submit it to PHP as well.
>
> The latest snapshot doesn't fix the problem.

Well, we don't see this problem with curl the command line tool and no 
application author have reported anything like this, so I'm pretty sure this 
problem is due to something PHP does and not anything within libcurl.

Of course, should someone produce some evidence suggesting otherwise I'll be 
interested in a stand-alone libcurl snippet that doesn't involve PHP that can 
reproduce the problem.

--

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

Michael Wallner | 3 Sep 2006 13:57
Picon
Gravatar

Re: Curl + php + ssl = free() invalid pointer

Tom Cannaerts wrote:
> Well, I submitted that bug yesterday, after doing some more searching. From
> what I've read, usually this error has got something to do with the way the
> program calls curl, so I decided to submit it to PHP as well.

Looking at your submitted backtrace it seems like a yaSSL incompatibility/bug to me.

Regards,
--

-- 
Michael

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

Gaetano Giunta | 5 Sep 2006 14:47
Picon

question: ssl through proxies

Hello.

I just discovered the joys of http 1.0 extension for tunneling ssl through proxies.
http://curl.haxx.se/rfc/draft-luotonen-web-proxy-tunneling-01.txt

I maintain some http client code, that takes advantage of curl when available. It should properly parse
responses that gotten back from https-connected web servers via a tunnelling proxy.

Do you think it is correct to use this check to extract the http headers inserted by the proxy in such a situation?

		// Support "web-proxy-tunelling" connections for https through proxies
				if(preg_match('/^HTTP\/1\.[0-1] 200 Connection established/', $data))
				{
					// Look for CR/LF or simple LF as line separator,
					// (even though it is not valid http)
					$pos = strpos($data,"\r\n\r\n");
					if($pos || is_int($pos))
					{
						$bd = $pos+4;
					}
					else
					{
						$pos = strpos($data,"\n\n");
						if($pos || is_int($pos))
						{
							$bd = $pos+2;
						}
						else
						{
							// No separation between response headers and body: fault?
							$bd = 0;
						}
					}
		

the part that leaves me most wondering is checking for the string "Connection established": do you happen
to know some proxies that use slight variations on the formula?

Any other known quirks? Do I risk loosing some useful information if I discard all http headers sent by the
proxy itself?

Note that curl apparently works, since it gives no errors in retrieving the response (and I need to get back
form curl a response with full http headers included).

Thanks
Gaetano Giunta

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

Daniel Stenberg | 5 Sep 2006 16:46
Picon
Favicon
Gravatar

Re: question: ssl through proxies

On Tue, 5 Sep 2006, Gaetano Giunta wrote:

> I maintain some http client code, that takes advantage of curl when 
> available. It should properly parse responses that gotten back from 
> https-connected web servers via a tunnelling proxy.
>
> Do you think it is correct to use this check to extract the http headers 
> inserted by the proxy in such a situation?

libcurl already separates the body from the header so I don't understand why 
you would do this as well. And if you do it yourself anyway, I suggest you 
read RFC2616 on how to do it and not just assume that proxies will use 
specific strings such as "Connection established".

--

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php


Gmane