From: <jeannie boffel> jboffel at gmail dot com
Operating system: Linux RedHat Enterprise
PHP version: 5.2.5
PHP Bug Type: SOAP related
Bug description: RFC2616 transgression while HTTPS request through proxy with
SoapClient object
Description:
------------
Configure line :
No need for a configure line here, just need the php extension soap.so
Setup :
You have to make a soap call on an https based webservice through an
Apache proxy (Apache or any proxy which is following rfc2616).
Explanation :
When you make an HTTPS connection in HTTP/1.1 through a proxy you MUST
include an host parameter in the HTTP header like that :
CONNECT uri-test:443 HTTP/1.1
Host: uri-test
And what's done today is :
CONNECT uri-test:443 HTTP/1.1
So we're clearly missing the Host parameter like explaining below,
rfc2616 require this :
A client MUST include a Host header field in all HTTP/1.1 request
messages . If the requested URI does not include an Internet host
name for the service being requested, then the Host header field MUST
be given with an empty value. An HTTP/1.1 proxy MUST ensure that any
request message it forwards does contain an appropriate Host header
field that identifies the service being requested by the proxy. All
Internet-based HTTP/1.1 servers MUST respond with a 400 (Bad Request)
status code to any HTTP/1.1 request message which lacks a Host header
field.
The problem is based in php_http.c in ext/soap/ of ANY existing version of
PHP (not only 5.2.5)
Well, there is two possible fix at least :
1) Add after line 169 :
smart_str_append_const(&soap_headers, "Host: ");
smart_str_appends(&soap_headers, phpurl->host);
smart_str_append_const(&soap_headers, "\r\n");
The problem here is that I'm NOT sure that every time in HTTPS connection
we need to put exactly the value of phpurl-host.
For example I don't know if it's possible to be in a situation like this :
(IP like x.x.x.x)
CONNECT IP:443 HTTP/1.1
Host: www.test.com
If yes, this fix is not perfect.
2) Modify line 169 from :
smart_str_append_const(&soap_headers, " HTTP/1.1\r\n");
to :
smart_str_append_const(&soap_headers, " HTTP/1.0\r\n");
Of course solution 2 force us to downgrade to protocol HTTP/1.0 which
won't be able to access HTTPS virtualhosted website on a single IP address.
Reproduce code:
---------------
Short script :
<?php
$client = new SoapClient("some.wsdl", array('proxy_host'=>"localhost",
'proxy_port'=>
8080,'uri'=>"https://test-uri/"));
$client->SomeFunction($a, $b, $c);
?>
Expected result:
----------------
HTTP header like that :
CONNECT uri-test:443 HTTP/1.1
Host: uri-test
Actual result:
--------------
CONNECT uri-test:443 HTTP/1.1
--
Edit bug report at http://bugs.php.net/?id=44248&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44248&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44248&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44248&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44248&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44248&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44248&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44248&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44248&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44248&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44248&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44248&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44248&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44248&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44248&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44248&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44248&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44248&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44248&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44248&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44248&r=mysqlcfg