peer certificate cn did not match expected laravel

Hello, buddy I hope you are doing well, in today’s article we will see how we can resolve the issue peer certificate did not match Stream Socket Enable Crypto Error in laravel.

If you are reading this article it means you are trying to send an email from your live server but you are unable to do so due to this CN did not match error.

Definitely, you go to the StackOverflow and some others sites as well for the solution, but I know that they didn’t help you out, as they have written the solution for laravel 6, laravel 7 and laravel 8

Because you are using laravel 9 lot many things have changed, if you wanted to know what comes new in the laravel 9 you can visit here.

To get rid of this error you just have to do a small tweak in config/mail.php file add the below in your smtp array

'verify_peer' => false,  

after adding the above code in your smtp array your entire code will look like the below one.

'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST', ''),
            'port' => env('MAIL_PORT', 587),
            'encryption' => env('MAIL_ENCRYPTION', 'tls'),
            'username' => env('MAIL_USERNAME'),
            'password' => env('MAIL_PASSWORD'),
            'timeout' => null,
            'auth_mode' => null,
            'verify_peer' => false,  

Now run the code you definitely not get the error cn did not match expected in laravel error.

Still the above tweaks not works for you, please add the comment in brief so that our member or other netigens will help you out.

Shaiv Roy

Hy Myself shaiv roy, I am a passionate blogger and love to share ideas among people, I am having good experience with laravel, vue js, react, flutter and doing website and app development work from last 7 years.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button