编者按:禁用SSL验证具有安全隐患。如果不验证 SSL/HTTPS 连接的真实性,恶意攻击者可能会冒充受信任的端点(如 Gmail),而您将容易受到中间人攻击。
在将其用作解决方案之前,请确保您完全了解安全问题。
我在laravel 4.2中也有这个错误,我以这种方式解决了。找出。对我来说,我使用xampp,我的项目名称是itis_db为此,我的路径是这样的。所以试着根据你的一个找到StreamBuffer.php
C:\xampp\htdocs\itis_db\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php
并在StreamBuffer中找出此功能.php
private function _establishSocketConnection()
并将这两行粘贴到此函数内
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
,然后重新加载浏览器并尝试再次运行项目。对我来说,我穿上了这样的衣服:
private function _establishSocketConnection()
{
$host = $this->_params['host'];
if (!empty($this->_params['protocol'])) {
$host = $this->_params['protocol'].'://'.$host;
}
$timeout = 15;
if (!empty($this->_params['timeout'])) {
$timeout = $this->_params['timeout'];
}
$options = array();
if (!empty($this->_params['sourceIp'])) {
$options['socket']['bindto'] = $this->_params['sourceIp'].':0';
}
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));
if (false === $this->_stream) {
throw new Swift_TransportException(
'Connection could not be established with host '.$this->_params['host'].
' ['.$errstr.' #'.$errno.']'
);
}
if (!empty($this->_params['blocking'])) {
stream_set_blocking($this->_stream, 1);
} else {
stream_set_blocking($this->_stream, 0);
}
stream_set_timeout($this->_stream, $timeout);
$this->_in = &$this->_stream;
$this->_out = &$this->_stream;
}
希望你能解决这个问题.....