Localhost and "stream_socket_enable_crypto (): SSL operation failed with code 1"

I sent emails using gmail and everything worked fine, but apparently it stopped working. And it shows me that.

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 

And this only happens in my local host, the web host works fine. I do not understand what is happening: c

These are my gmail settings

 MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=gmail MAIL_PASSWORD=password MAIL_ENCRYPTION=tls 
+11
source share
5 answers

This is a mistake with your SSL certificate. You are trying to use an SSL connection (encrypted secure connection) without a proper certificate.

This is because you are connecting to a local host, which is insecure and which is blocked by the connection. You could avoid this by changing your localhost connection to SSL-based.

See this link for more details.

+9
source

You should add the code below to /config/mail.php (works on laravel 5.4)

 'stream' => [ 'ssl' => [ 'allow_self_signed' => true, 'verify_peer' => false, 'verify_peer_name' => false, ], ], 

since you should never change the code in suppliers, as suggested by Sultan Ahmad

Editor's Note : disabling SSL verification has security implications. Without SSL / HTTPS authentication, an attacker could pretend to be a trusted endpoint (such as GitHub or some other remote Git host) and you will be vulnerable to a man in the middle attack . Make sure that you fully understand the security issues before using this as a solution.

+33
source

I had the same problem and was able to solve the problem by removing the authentication security level. That is, at some point, Gmail asked me to specify a phone number - the 2nd level of authentication. When I removed this 2nd level, I was happy again. Hope I helped.

+1
source

Hi, I also found this very useful at the server level: Edit \ vendor \ swiftmailer \ lib \ classes \ Swift \ Transport \ StreamBuffer.php line 259 ish. comment out $ options = array (); and add below.

 $options = array(); $options['ssl'] = array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true); 

This work with Laravel 6.0

0
source

in Laravel: this will solve the problem. go to \vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php

inside the method, the private function installSocketConnection ()

after this code

 $options = array(); if (!empty($this->params['sourceIp'])) { $options['socket']['bindto'] = $this->params['sourceIp'].':0'; } 

then add two lines

 $options['ssl']['verify_peer'] = FALSE; $options['ssl']['verify_peer_name'] = FALSE; 
-1
source

Source: https://habr.com/ru/post/1268644/


All Articles