|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-04-15 01:52 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
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);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'.I am seeing the same error. It appears to be generated after the following loop has completed. More specifically, the Warning message is emitted just after the loop terminates. while( !feof($handle) ) { echo "Looping to read in all of the reply.<br>"; $reply .= fgets($handle); } PHP 4.3.4 compiled with --with-openssl What other information would be helpful?This also seems to cause a problem with file_get_contents which I am using to retrieve transaction data. Test case is: <code><?php file_get_contents("https://any.secure.server"); ?></code> returns: <code>Warning: file_get_contents(): SSL: fatal protocol error in /usr/local/www/data-dist/navdev/test.php on line 2</code> ...plus whatever data the secure server provides.Since this indeed an error but it will happen anytime you make an HTTPS request to IIS i think the error should be changed to E_NOTICE and the error message updated to what it actually does. Patch --- diff -u network.c network.c.patched --- network.c 2004-02-17 01:20:49.000000000 +0000 +++ network.c.patched 2004-02-17 01:22:23.000000000 +0000 @@ -870,8 +870,8 @@ case SSL_ERROR_SYSCALL: if (ERR_peek_error() == 0) { if (nr_bytes == 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, - "SSL: fatal protocol error"); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, + "SSL: EOF occurred in violation of protocol"); stream->eof = 1; retry = 0; } else {I'm seeing this against an apache server. What version is this fixed in? file_get_contents("https://....."); PHP 4.3.2 (cgi), Copyright (c) 1997-2003 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies I have fixed it for now with error_reporting but would like to get a true fix.PHP Version 5.0.0RC2 Configure Command './configure' '--with-openssl' ... if ( $fp = fopen("https://xxxxxxxx, "r") ) { while ( $row = fgets($fp, 1024) ) { print($row); } fclose($fp); } Warning: fgets() [function.fgets]: SSL: fatal protocol error in xxxxxxxxxxxxxxxxxxx.php on line xx however it GETS the data...Hi, this bug still exists on php4-STABLE-200405031430. ;-( System: - Linux (RedHat 8) 2.4.20-28.8 #1 Thu Dec 18 12:53:39 EST 2003 i686 i686 i386 GNU/Linux - php4-STABLE-200405031430 - OpenSSL 0.9.6b Configure command: './configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-mysql' '--with-openssl' '--with-sapdb=/opt/sapdb/interfaces/odbc/' php-script: <?php $url = "https://foo.bar"; file_get_contents($url); ?> Output: Warning: file_get_contents(): SSL: fatal protocol error in /www/www.default.de/html/https2.php on line 3 Any help for me? Greetings grizu