php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30217 XML RPC 1.1.0 doesn't operate over ssl properly
Submitted: 2004-09-24 11:30 UTC Modified: 2004-09-28 16:01 UTC
From: nkukard at lbsd dot net Assigned:
Status: Not a bug Package: XML related
PHP Version: 5.0.1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
26 + 5 = ?
Subscribe to this entry?

 
 [2004-09-24 11:30 UTC] nkukard at lbsd dot net
Description:
------------
XML RPC doesn't allow for communication over ssl and uses the incorrect information in the http headers.

Here is a patch to fix the problem...

diff -u --recursive XML_RPC-1.1.0_vanilla/RPC.php XML_RPC-1.1.0_xmlrpcssl/RPC.php
--- XML_RPC-1.1.0_vanilla/RPC.php       2004-03-15 15:51:44.000000000 +0200
+++ XML_RPC-1.1.0_xmlrpcssl/RPC.php     2004-05-01 18:54:11.991190696 +0200
@@ -452,16 +452,37 @@
     {
         // If we're using a proxy open a socket to the proxy server instead to the xml-rpc server
         if ($this->proxy){
+            $proxy_server = $this->proxy;
+            $proxy_proto = "";
+            if (strstr($proxy_server,"https://"))
+            {
+                $proxy_server = substr($proxy_server,8);
+                $proxy_proto = "ssl://";
+            }
+            // Backward compatibility
+            if (!strstr($proxy_server,"http://"))
+            {
+                $server = "http://" . $server;
+            }
             if ($timeout > 0) {
-                $fp = fsockopen($this->proxy, $this->proxy_port, $this->errno, $this->errstr, $timeout);
+                $fp = fsockopen($proxy_proto . $this->proxy, $this->proxy_port, $this->errno, $this->errstr, $timeout);
             } else {
-                $fp = fsockopen($this->proxy, $this->proxy_port, $this->errno, $this->errstr);
+                $fp = fsockopen($proxy_proto . $this->proxy, $this->proxy_port, $this->errno, $this->errstr);             }
         } else {
+            $server_proto = "";
+            if (strstr($server,"https://"))
+            {
+                $server = substr($server,8);
+                $server_proto = "ssl://";
+            } elseif (strstr($server,"http://"))
+            {
+                $server = substr($server,7);
+            }
             if ($timeout > 0) {
-                $fp = fsockopen($server, $port, $this->errno, $this->errstr, $timeout);
+                $fp = fsockopen($server_proto . $server, $port, $this->errno, $this->errstr, $timeout);
             } else {
-                $fp = fsockopen($server, $port, $this->errno, $this->errstr);
+                $fp = fsockopen($server_proto . $server, $port, $this->errno, $this->errstr);
             }
         }

@@ -489,7 +510,7 @@


         if ($this->proxy) {
-            $op = "POST http://" . $this->server;
+            $op = "POST ". $server;

             if ($this->proxy_port) {
                 $op .= ":" . $this->port;
@@ -500,7 +521,7 @@

         $op .= $this->path. " HTTP/1.0\r\n" .
                "User-Agent: PEAR XML_RPC\r\n" .
-               "Host: " . $this->server . "\r\n";
+               "Host: " . $server . "\r\n";
         if ($this->proxy && $this->proxy_user != '') {
             $op .= 'Proxy-Authorization: Basic ' .
                 base64_encode($this->proxy_user . ':' . $this->proxy_pass) .
@@ -660,7 +681,7 @@
     {
         $ipd = "";

-        while($data = fread($fp, 32768)) {
+        while($data = @fread($fp, 32768)) {
             $ipd .= $data;
         }
         return $this->parseResponse($ipd);



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-28 16:01 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

This is a bug in the PEAR class, please re-submit your bug report and the patch to http://pear.php.net/bugs/.

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC