ID: 23220
Comment by: derek at openflows dot org
Reported By: storozhilov at mail dot ru
Status: Assigned
Bug Type: Filesystem function related
Operating System: FreeBSD 4.8
PHP Version: 4-STABLE-200307070330
Assigned To: wez
New Comment:
This is a followup to the comment posted by
[21 Aug 8:18pm EDT] scottm at spamcop dot net, as well as a plea to the
php developers to correct this problem in future versions of php.
After many long hours trying to debug the exact problem described here
(as well as many other places on the net), but finding no concrete
solutions, I eventually tried scottm's patch to network.c, using php
4.3.3. Thankfully, this fix does work, and i'm hoping that the two
lines indicated get tweaked in upcoming versions.
If you are experiencing this problem with reading an https url with any
of php's filesystem-related functions, definitely try patching and
recompiling your php source as indicated. I've confirmed this to be a
working solution for my application.
Previous Comments:
------------------------------------------------------------------------
[2003-10-26 14:41:20] [EMAIL PROTECTED]
Re-opening at user request.
Users comments that have mysteriously vanished are:
===================================================
See the code below to verify , I'm not able to alter php versions
since
it's hosted with my ISP so please test it with the latest version so
it
can be closed as being fixed or further investigation needed.
<?php
$method = "ssl://";
$host = "memberservices.passport.net";
$port = 443;
$url = "/";
$file = fsockopen($method.$host,$port,$errno,$errstr,30);
if(!$file) {
print ("error");
exit;
}
fputs($file,"GET ".$url." HTTP/1.1\r\n");
fputs($file,"Host: ".$host."\r\n");
fputs($file,"Connection: Keep-Alive\r\n");
fputs($file,"Cache-Control: no-cache\r\n\r\n");
while(!feof($file)) {
$output = fgets ($file, 1024);
}
fclose($file);
?>
output:
PHP Warning: fgets(): SSL: fatal protocol error in
/path.to/test_ssl.php on line 18
Please put the bug to 'open'.
------------------------------------------------------------------------
[2003-10-08 07:30:39] [EMAIL PROTECTED]
Could you try the next stable snapshot (due in a few minutes)?
I comitted a fix for a different bug that might make a
difference to this one.
If it hasn't fixed it, could you post an https:// URL
that reproduces the problem, so that I can investigate
further?
------------------------------------------------------------------------
[2003-08-21 20:18:33] scottm at spamcop dot net
I've not verified this patch will work and I'll hopefully test it
tomorrow.
I believe it is reaching the end of the file and nr_bytes is returning
0 and this is being caught by an if statement which should be looking
for -1.
--- network.c Thu Aug 21 21:06:43 2003
+++ network.c.patched Thu Aug 21 21:13:09 2003
@@ -1011,13 +1011,14 @@
do {
nr_bytes = SSL_read(sock->ssl_handle, buf,
count);
- if (nr_bytes <= 0) {
+ if (nr_bytes < 0) {
retry = handle_ssl_error(stream,
nr_bytes TSRMLS_CC);
if (retry == 0 &&
!SSL_pending(sock->ssl_handle)) {
stream->eof = 1;
}
} else {
- /* we got the data */
+ /* we got the data */
+ stream->eof = 1;
break;
}
} while (retry);
------------------------------------------------------------------------
[2003-04-15 01:52:09] storozhilov at mail dot ru
<?php
$fd = fsockopen(
'ssl://www.somehost.com',
443,
$errno,
$errstr,
30
);
fputs($fd, "GET / HTTP/1.0\r\n\r\n");
while (!feof($fd)) {
echo fgets($fd, 1024);
);
?>
After executing of this script following message appears:
Warning: fgets() [function.fgets]: SSL: fatal protocol error in
/blah/blah/blah/blah.php on line NN
PHP was configured with following arguments:
#!/bin/sh
./configure --with-apache=../apache_1.3.27rusPL30.17 --with-mod_charset
--with-pgsql=/usr/local/pgsql --with-mhash --with-sybase=/usr/local
--with-openssl
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23220&edit=1