29

I transfer my application from Laravel 4 to Laravel 5, in sending email particularly in (reset Password).. I got this error

stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL

Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

but in laravel 4, it works.

Community
  • 1
  • 1
jle2389
  • 299
  • 3
  • 3
  • 1
    hi Roopendra, this is the error msg, ErrorException in StreamBuffer.php line 95: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed. Thank you.. – jle2389 Apr 27 '15 at 09:03
  • 1
    Are you using queues for sending your mails? Do you have a background queue process running? – Mysteryos Apr 27 '15 at 09:20
  • 1
    Hi Mysteryos, I'm just follow the default configuration of mail in laravel 5 framework, actually i have no background in queue process running...:( Thank you @Mysteryos.. – jle2389 Apr 27 '15 at 09:29
  • 4
    Seems like the default configuration `sendmail` doesn't work for you. You might want to switch to smtp mail. Check google's settings for SMTP server: https://support.google.com/a/answer/176600?hl=en – Mysteryos Apr 27 '15 at 09:33
  • 1
    Okay @Mysteryos i will try gmail smtp server, just like i use before, but in this case, this error is possible made by no ssl certificate in server? and to fix this using private email, the server must have a ssl certificate? – jle2389 Apr 27 '15 at 09:39
  • 4
    Yeah, gmail will have their own ssl certificate. So you won't stumble on this error. – Mysteryos Apr 27 '15 at 09:41
  • 1
    hi @mysteryos, it's work now, i use gmail smtp.. thank you again... cheers.. – jle2389 Apr 27 '15 at 10:22
  • 1
    I believe the issue lie with the PHP5.6. And not with older version of PHP. As the documentation on php.net, they have made peer verify and hostname by default when using SSL/TLS. For more detail check this http://php.net/manual/en/migration56.openssl.php – Ramesh Dahiya Aug 12 '15 at 16:48
  • 3
    mysteryos, please write out your solution as an answer. That way people can up vote it. Otherwise, this question looks like it doesn't have a solution. – arikin Aug 13 '15 at 01:45
  • 2
    possible duplicate of [PHPMailer - SSL3\_GET\_SERVER\_CERTIFICATE:certificate verify failed](http://stackoverflow.com/questions/26827192/phpmailer-ssl3-get-server-certificatecertificate-verify-failed) – philipxy Aug 30 '15 at 08:53
  • 1
    @arikin Your comment is missing the @ to notify mysteryos. – philipxy Sep 04 '15 at 07:34
  • 1
    It is a bug in Swiftmailer: http://stackoverflow.com/questions/25045963/laraval-queue-daemon-mail-stops-functioning-with-ssl-error – lucidlogic May 03 '16 at 19:22
  • 1
    I also got the same error while using my own mail server. After researching i came to know that this error was due to ssl certification.So i switch to [ https://www.mailgun.com/ ] (mailgun). This will resolve the issue.Its free for 10000 mails. – Manish Sep 13 '16 at 12:24
  • 1
    How did 15 people think this question was worthy of an upvote? Mind boggling! – miken32 Jan 17 '17 at 23:58
  • 2
    Possible duplicate of [OpenSSL Error messages: error:14090086:SSL routines:SSL3\_GET\_SERVER\_CERTIFICATE:certificate verify failed Failed to enable crypto](https://stackoverflow.com/questions/32019623/openssl-error-messages-error14090086ssl-routinesssl3-get-server-certificate) –  Jun 14 '17 at 07:22
  • 1
    @jle2389 Any luck finding better solution ? Have you tried below solutions ? – Pratik Soni Jun 19 '17 at 13:57

7 Answers7

4

I faced similar problem so I set

MAIL_ENCRYPTION= in .env file.

and it worked fine for me.

1

This error means that the SSL certificate verification is failing.
A quick fix would be to add to StreamBuffer.php these lines right after the condition:

if (!empty($this->_params['sourceIp']))

$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
Raz Weizman
  • 89
  • 2
  • 10
  • 2
    This is only a quick fix as it effectively disables the authentication of the server being connected to. Any other system could intercept the traffic. Curl in PHP often defaults to an empty CA store for certificate validation, so the same issue could be occurring here. See if openssl_get_cert_locations() reveals any clues and ensure your CA store is up to date. – Steve E. Oct 27 '16 at 23:59
1

If you are using basically Windows for development this is the common problem.

Changing your mail driver to "mail" from "smtp" will help.

1

you can use google app password ,for me it worked after changing the gmail password with app password you can do that by visiting my account>sign in>

1

Go to location \vendor\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php en la linea 259.Comment the following:

//$options = array();

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

:D!

Matu95
  • 17
  • 1
1

Add

$mail->SMTPOptions = array(
   'ssl' => array(
   'verify_peer' => false,
   'verify_peer_name' => false,
   'allow_self_signed' => true
 ));

before

mail->send()

and replace

require "mailer/class.phpmailer.php";

with

require "mailer/PHPMailerAutoload.php";
Vajiheh Habibi
  • 379
  • 1
  • 4
  • 16
1

That's an error with your SSL certificate. You are trying to use a SSL connection (encrypted, secure connection) without a proper certificate.

That's because you are connecting from localhost, which is not secure, and that is blocked by the connection. You could avoid that by changing your localhost connection to a SSL based one.

Also check and add below code in 'config/mail.php' this file.

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

Kiran Kanzar
  • 329
  • 1
  • 5
  • 14