#50025 [Opn->Fbk]: You have to fgets() after STARTTLS or stream_socket_enable_crypto() won't work

From: Date: Tue, 27 Oct 2009 22:28:39 +0000
Subject: #50025 [Opn->Fbk]: You have to fgets() after STARTTLS or stream_socket_enable_crypto() won't work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-144035@lists.php.net to get a copy of this message
ID: 50025 Updated by: jani@php.net Reported By: wooptoo at gmail dot com -Status: Open +Status: Feedback Bug Type: Streams related Operating System: Linux x86_64 PHP Version: 5.3.0 New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Previous Comments: ------------------------------------------------------------------------ [2009-10-27 20:23:50] wooptoo at gmail dot com Description: ------------ You have to fgets() the output from the socket after STARTTLS or stream_socket_enable_crypto() won't work on SMTP. This is on SMTP. I didn't test on other protocols. Why is the fgets() necessary? Reproduce code: --------------- <?php $conn = fsockopen($server, $port, $errno, $errstr, $timeout); fputs($conn, 'HELO localhost'."\r\n"); fputs($conn, 'STARTTLS'."\r\n"); // why is this necessary? : fgets($conn); stream_socket_enable_crypto($conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); fputs($conn, 'HELO localhost'."\r\n"); ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50025&edit=1

« previous php.bugs (#144035) next »