Home » Networking » Net_Socket » Bug #7266
Can Open https connection through HTTP_Request
Details
| Submitted | 2006-03-30 20:49 UTC |
|---|---|
| From | jason at bouquetoffruits dot com |
| Status | Bogus |
| Package | Net_Socket |
| PHP Version | 4.3.10 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2006-03-30 20:49 UTC] jason at bouquetoffruits dot com
Description:
------------
script fails when the url is changed from a tcp connection to an ssl connection.
Using:
Package Version State
Archive_Tar 1.1 stable
Console_Getopt 1.2 stable
DB 1.6.2 stable
HTTP 1.4.0 stable
HTTP_Client 1.0.0 stable
HTTP_Download 1.1.1 stable
HTTP_Header 1.2.0 stable
HTTP_Request 1.3.0 stable
Mail 1.1.3 stable
Net_SMTP 1.2.6 stable
Net_Socket 1.0.6 stable
Net_URL 1.0.14 stable
PEAR 1.3.2 stable
XML_Parser 1.0.1 stable
XML_RPC 1.1.0 stable
Error Happens on Line 143 of Socket.php $fp is not set as it should on line 138 of Socket.php
Attempts to change the $addr variable from ssl://ssl.bouquetoffruits.com to ssl.bouquetoffruits.com or 66.126.130.169 didn't at line 137 didn't solve the problem either.
Test script:
---------------
<?php
$url = "https://ssl.bouquetoffruits.com/test.php";
//$url = "http://www.bouquetoffruits.com/test.php";
require_once "PEAR.php";
require_once "HTTP.php";
require_once "HTTP/Request.php";
require_once "HTTP/Client.php";
// Create the HTTP_Request object, specifying the URL
$Request = & new HTTP_Request($url,array("method"=>"POST"));
$Request->addHeader("Request", "POST test.php HTTP/1.1");
$Request->addHeader("Content-Type", "text/xml");
$Request->addRawPostData("Test Post Raw Data");
$ErrorCheck = $Request->sendRequest();
// Check for errors
if ( PEAR::isError($ErrorCheck) ) {
die ( "Connection problem: ".$ErrorCheck->toString() );
}
// Check we got an HTTP 200 status code (if not there's a problem)
if ( $Request->getResponseCode() != '200' ) {
die ( "Request failed: ".$Request->getResponseCode() );
}
// Get the body of the response - the XML document
$xml = $Request->getResponseBody();
//Display Output
echo "<pre>";
print_r ( $xml );
echo "</pre>";
?>
Expected result:
----------------
Array
(
[HTTP_HOST] => www.bouquetoffruits.com
[HTTP_USER_AGENT] => PEAR HTTP_Request class ( http://pear.php.net/ )
[HTTP_CONNECTION] => close
[HTTP_ACCEPT_ENCODING] => gzip
[HTTP_REQUEST] => POST test.php HTTP/1.1
[CONTENT_TYPE] => text/xml
[CONTENT_LENGTH] => 18
[PATH] => /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
[SERVER_SIGNATURE] =>
[SERVER_SOFTWARE] => Apache
[SERVER_NAME] => www.bouquetoffruits.com
[SERVER_ADDR] => 66.126.130.169
[SERVER_PORT] => 80
[REMOTE_ADDR] => 66.126.130.172
[DOCUMENT_ROOT] => /usr/local/www/html/bouquetoffruits
[SERVER_ADMIN] => bouquetoffruits.com
[SCRIPT_FILENAME] => /usr/local/www/html/bouquetoffruits/test.php
[REMOTE_PORT] => 39435
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => POST
[QUERY_STRING] =>
[REQUEST_URI] => /test.php
[SCRIPT_NAME] => /test.php
[PHP_SELF] => /test.php
[PATH_TRANSLATED] => /usr/local/www/html/bouquetoffruits/test.php
[argv] => Array
(
)
[argc] => 0
)
Raw Post Data: Test Post Raw Data
Actual result:
--------------
Connection problem: [pear_error: message="Success" code=0 mode=return level=notice prefix="" info=""]
[2006-03-31 17:55 UTC] jason at bouquetoffruits dot com
<?php
$myconnection=fsockopen('ssl://ssl.bouquetoffruits.com', '443',$error);
if($myconnection){
print "Connected $error<Br>\n";
fclose($myconnection);
}else print "NOT Connected $error<br>\n";
?>
returns:
Warning: fsockopen(): no SSL support in this build in phpfile.php on line 55 Warning: fsockopen(): unable to connect to ssl.bouquetoffruits.com:443
NOT Connected 13
This should have been reported by the object.
My configure line for php is:
'./configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-mysql=/usr/local/mysql' '--with-zlib' '--with-curl=/usr/lib/' '--with-curlwrappers' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--enable-track-vars' '--with-openssl' '--with-imap' '--enable-sysvsem' '--enable-sysvshm' '--enable-sockets' '--with-gettext' '--enable-exif' '--with-jpeg' '--with-zlip' '--with-kerberos'
openssl reports:
OpenSSL support enabled
OpenSSL Version OpenSSL 0.9.7f 22 Mar 2005
[2006-03-31 19:11 UTC] jason at bouquetoffruits dot com
Problem solved! The connection issue was fixed by upgradeing to php v4.4.2