Home » Web Services » XML_RPC » Bug #2489
XML RPC doesn't allow for proper communication over ssl
Details
| Submitted | 2004-10-10 14:08 UTC |
|---|---|
| From | nkukard at lbsd dot net |
| Assigned | danielc |
| Status | Closed |
| Package | XML_RPC |
| PHP Version | Irrelevant |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2004-10-10 14:08 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.
Reproduce code:
---------------
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);