Commit e8e89585 authored by efalcy's avatar efalcy
Browse files

hotline #77270 : add crypto stream methods for compatibility with php > 5.6 for mail

parent 7fed0bfe
......@@ -11,7 +11,7 @@
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
*
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
......@@ -104,17 +104,34 @@ class Zend_Mail_Protocol_Imap
if ($ssl === 'TLS') {
$result = $this->requestAndResponse('STARTTLS');
$result = $result && stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
if (!$result) {
/**
* @see Zend_Mail_Protocol_Exception
*/
require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('cannot enable TLS');
}
$result = $result && $this->_connectViaTLS();
}
}
protected function _connectViaTLS() {
$success = false;
$modes = defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')
? array(
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT,
STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT,
)
: array(
STREAM_CRYPTO_METHOD_TLS_CLIENT,
);
foreach($modes as $mode) {
$success = stream_socket_enable_crypto($this->_socket, true, $mode);
if ($success) return true;
}
require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('Unable to connect via TLS');
}
/**
* get the next line from socket with error checking, but nothing else
*
......@@ -189,8 +206,8 @@ class Zend_Mail_Protocol_Imap
"foo" baz {3}<NL>bar ("f\\\"oo" bar)
would be returned as:
array('foo', 'baz', 'bar', array('f\\\"oo', 'bar'));
// TODO: add handling of '[' and ']' to parser for easier handling of response text
// TODO: add handling of '[' and ']' to parser for easier handling of response text
*/
// replace any trailling <NL> including spaces with a single space
$line = rtrim($line) . ' ';
......@@ -818,7 +835,7 @@ class Zend_Mail_Protocol_Imap
if (!$response) {
return $response;
}
foreach ($response as $ids) {
if ($ids[0] == 'SEARCH') {
array_shift($ids);
......
......@@ -11,7 +11,7 @@
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
*
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
......@@ -114,19 +114,34 @@ class Zend_Mail_Protocol_Pop3
if ($ssl === 'TLS') {
$this->request('STLS');
$result = stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
if (!$result) {
/**
* @see Zend_Mail_Protocol_Exception
*/
require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('cannot enable TLS');
}
$result = $this->_connectViaTLS();
}
return $welcome;
}
protected function _connectViaTLS() {
$success = false;
$modes = defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')
? array(
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT,
STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT,
)
: array(
STREAM_CRYPTO_METHOD_TLS_CLIENT,
);
foreach($modes as $mode) {
$success = stream_socket_enable_crypto($this->_socket, true, $mode);
if ($success) return true;
}
require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('Unable to connect via TLS');
}
/**
* Send a request
......
......@@ -12,7 +12,7 @@
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
*
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
......@@ -38,7 +38,7 @@ require_once 'Zend/Mail/Protocol/Abstract.php';
* Smtp implementation of Zend_Mail_Protocol_Abstract
*
* Minimum implementation according to RFC2821: EHLO, MAIL FROM, RCPT TO, DATA, RSET, NOOP, QUIT
*
*
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
......@@ -203,13 +203,7 @@ class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract
if ($this->_secure == 'tls') {
$this->_send('STARTTLS');
$this->_expect(220, 180);
if (!stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
/**
* @see Zend_Mail_Protocol_Exception
*/
require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('Unable to connect via TLS');
}
$this->_connectViaTLS();
$this->_ehlo($host);
}
......@@ -218,6 +212,28 @@ class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract
}
protected function _connectViaTLS() {
$success = false;
$modes = defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')
? array(
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT,
STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT,
)
: array(
STREAM_CRYPTO_METHOD_TLS_CLIENT,
);
foreach($modes as $mode) {
$success = stream_socket_enable_crypto($this->_socket, true, $mode);
if ($success) break;
}
require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('Unable to connect via TLS');
}
/**
* Send EHLO or HELO depending on capabilities of smtp host
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment