|
|
@@ -387,12 +387,19 @@ class TcpConnection extends ConnectionInterface
|
|
|
{
|
|
|
// SSL handshake.
|
|
|
if ($this->transport === 'ssl' && $this->_sslHandshakeCompleted !== true) {
|
|
|
- stream_set_blocking($socket, true);
|
|
|
- stream_set_timeout($socket, 1);
|
|
|
$ret = stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER);
|
|
|
- if(!$ret) {
|
|
|
- echo new \Exception('ssl handshake fail, stream_socket_enable_crypto return ' . var_export($ret, true));
|
|
|
+ // Negotiation has failed.
|
|
|
+ if(false === $ret) {
|
|
|
+ $error = error_get_last();
|
|
|
+ $error_msg = '';
|
|
|
+ if ($error) {
|
|
|
+ $error_msg = "{$error['message']} in {$error['file']} on line {$error['line']}";
|
|
|
+ }
|
|
|
+ echo new \Exception("SSL handshake fail $error_msg");
|
|
|
return $this->destroy();
|
|
|
+ } elseif(0 === $ret) {
|
|
|
+ // There isn't enough data and should try again.
|
|
|
+ return;
|
|
|
}
|
|
|
if (isset($this->onSslHandshake)) {
|
|
|
try {
|