Re: Problem with fsockopen and SSL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Barry,

I'm not terrible au fait with the workings of SSL, but it strikes me as
potentially problematic that you are communicating in plain text over an
encrypted protocol.  Might that be the problem?

David

Barry wrote:
> Hi everyone!
> 
> I want to connect to an SSL server but i can't get the content :(
> 
> Here is the code i use:
> $xml = '<xml><data>Hello!</data></xml>';
> 
> function PostToHost($host, $path, $referer, $data_to_send) {
>   $fp = fsockopen($host, 443);
>   printf("Open!\n");
>   fputs($fp, "POST $path HTTP/1.1\r\n\r\n");
>   fputs($fp, "Host:$host\r\n");
>   fputs($fp, "Referer: $referer\r\n");
>   fputs($fp, "Content-type: text/xml\r\n");
>   fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
>   fputs($fp, "Connection: close\r\n");
>   //fputs($fp, $data_to_send);
>   printf("Sent!\n");
>   while(!feof($fp)) {
>       $res .= fgets($fp, 128);
>   }
>   printf("Done!\n");
>   fclose($fp);
> 
>   return $res;
> }
> 
> $data = $xml;
> 
> printf("Go!\n");
> $x = PostToHost(
>               "ssl://easy-demo.tcinternet.de",
>               "/hosting/servlet/Dispatcher",
>               $GLOBALS["HTTP_REFERER"],
>               $data
> );
> echo $x;
> 
> And this is what i get:
> Go! Open! Sent! Done! HTTP/1.1 400 Bad Request Date: Mon, 09 Jan 2006
> 10:28:48 GMT Server: Apache/2.0.53 (Unix) mod_ssl/2.0.53 OpenSSL/0.9.7e
> DAV/2 mod_jk/1.2.1 Content-Length: 363 Connection: close Content-Type:
> text/html; charset=iso-8859-1
> Bad Request
> 
> Your browser sent a request that this server could not understand.
> Apache/2.0.53 (Unix) mod_ssl/2.0.53 OpenSSL/0.9.7e DAV/2 mod_jk/1.2.1
> Server at easy-demo.tcinternet.de Port 443
> 
> What did the Webserver not understood?
> 
> Btw. i can't use cURL because the server has an old version of PHP (><)"
> 
> Would be glad if you can help or even have a code how to connect to a
> SSL webserver via fsockopen that works.
> 
> Btw the PHP version on server is: PHP Version 4.2.2
> 
> Thanks for any help!
> 
> Greets Barry
> 


-- 
David Grant
http://www.grant.org.uk/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux