本地主机和 "stream_socket_enable_crypto(): SSL operation failed with code 1"
localhost and "stream_socket_enable_crypto(): SSL operation failed with code 1"
我正在使用 gmail 发送电子邮件,一切正常,但突然停止工作。它向我展示了这个
ErrorException in StreamBuffer.php line 94:
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
in StreamBuffer.php line 94
at HandleExceptions->handleError('2', 'stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed', 'C:\xampp\htdocs\coparmex\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php', '94', array())
at stream_socket_enable_crypto(resource, true, '9') in StreamBuffer.php line 94
at Swift_Transport_StreamBuffer->startTLS() in EsmtpTransport.php line 313
at Swift_Transport_EsmtpTransport->_doHeloCommand() in AbstractSmtpTransport.php line 118
at Swift_Transport_AbstractSmtpTransport->start() in Mailer.php line 79
at Swift_Mailer->send(object(Swift_Message), array()) in Mailer.php line 385
at Mailer->sendSwiftMessage(object(Swift_Message)) in Mailer.php line 171
这只发生在我的本地主机上,在网络主机上工作正常。我不明白发生了什么:c
这些是我的 Gmail 设置
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=gmail
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
这是您的 SSL 证书错误。您正在尝试使用没有正确证书的 SSL 连接(加密的安全连接)。
那是因为您是从不安全的本地主机连接的,并且被连接阻止了。您可以通过将本地主机连接更改为基于 SSL 的连接来避免这种情况。
有关详细信息,请参阅 。
我遇到了同样的问题,并且能够通过删除身份验证安全级别来解决。也就是说,在某些时候 Gmail 要求我提供 phone 号码 - 二级身份验证。当我删除第 2 级时,我又高兴了。希望对您有所帮助。
in Laravel :这将解决问题。
前往 \vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php
内部方法
私有函数 establishSocketConnection()
在此代码之后
$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;
Editor's note: disabling SSL verification has security implications. Without verification of the authenticity of SSL/HTTPS connections, a malicious attacker can impersonate a trusted endpoint (such as GitHub or some other remote Git host), and you'll be vulnerable to a Man-in-the-Middle Attack. Be sure you fully understand the security issues before using this as a solution.
您应该在 /config/mail.php 中添加以下代码(在 laravel 5.4 上工作)
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
因为您永远不应该按照 Sultan Ahmad 的建议更改供应商中的代码
您好,我还发现这在服务器级别非常有用:
编辑 \vendor\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php
第 259 行左右。注释掉 $options = array();并添加以下内容。
$options = array();
$options['ssl'] = array('verify_peer' => false,
'verify_peer_name' => false, 'allow_self_signed' => true);
这适用于 Laravel 6.0
在.htaccess中添加以下内容
php_value openssl.cafile “cacert.pem 的路径”
我正在使用 gmail 发送电子邮件,一切正常,但突然停止工作。它向我展示了这个
ErrorException in StreamBuffer.php line 94:
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
in StreamBuffer.php line 94
at HandleExceptions->handleError('2', 'stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed', 'C:\xampp\htdocs\coparmex\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php', '94', array())
at stream_socket_enable_crypto(resource, true, '9') in StreamBuffer.php line 94
at Swift_Transport_StreamBuffer->startTLS() in EsmtpTransport.php line 313
at Swift_Transport_EsmtpTransport->_doHeloCommand() in AbstractSmtpTransport.php line 118
at Swift_Transport_AbstractSmtpTransport->start() in Mailer.php line 79
at Swift_Mailer->send(object(Swift_Message), array()) in Mailer.php line 385
at Mailer->sendSwiftMessage(object(Swift_Message)) in Mailer.php line 171
这只发生在我的本地主机上,在网络主机上工作正常。我不明白发生了什么:c
这些是我的 Gmail 设置
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=gmail
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
这是您的 SSL 证书错误。您正在尝试使用没有正确证书的 SSL 连接(加密的安全连接)。
那是因为您是从不安全的本地主机连接的,并且被连接阻止了。您可以通过将本地主机连接更改为基于 SSL 的连接来避免这种情况。
有关详细信息,请参阅
我遇到了同样的问题,并且能够通过删除身份验证安全级别来解决。也就是说,在某些时候 Gmail 要求我提供 phone 号码 - 二级身份验证。当我删除第 2 级时,我又高兴了。希望对您有所帮助。
in Laravel :这将解决问题。
前往 \vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php
内部方法 私有函数 establishSocketConnection()
在此代码之后
$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;
Editor's note: disabling SSL verification has security implications. Without verification of the authenticity of SSL/HTTPS connections, a malicious attacker can impersonate a trusted endpoint (such as GitHub or some other remote Git host), and you'll be vulnerable to a Man-in-the-Middle Attack. Be sure you fully understand the security issues before using this as a solution.
您应该在 /config/mail.php 中添加以下代码(在 laravel 5.4 上工作)
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
因为您永远不应该按照 Sultan Ahmad 的建议更改供应商中的代码
您好,我还发现这在服务器级别非常有用: 编辑 \vendor\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php 第 259 行左右。注释掉 $options = array();并添加以下内容。
$options = array();
$options['ssl'] = array('verify_peer' => false,
'verify_peer_name' => false, 'allow_self_signed' => true);
这适用于 Laravel 6.0
在.htaccess中添加以下内容
php_value openssl.cafile “cacert.pem 的路径”