Home  >  Article  >  Backend Development  >  How to Fix \"Certificate Verify Failed\" Errors When Sending TLS Emails with Laravel?

How to Fix \"Certificate Verify Failed\" Errors When Sending TLS Emails with Laravel?

Patricia Arquette
Patricia ArquetteOriginal
2024-10-31 02:58:01639browse

How to Fix

Troubleshooting "Certificate Verify Failed" Errors in Laravel TLS Email Sending

Problem:

When attempting to send TLS-encrypted emails via Gmail using Laravel 5.5, PHP 7.1.4, and Apache httpd 2.4 on Windows 10, errors such as "stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed" are encountered.

Solution:

To resolve the "certificate verify failed" error, follow these steps:

1. Download cURL cacert.pem Certificate Bundle:

  • Navigate to the following URL: https://github.com/bagder/ca-bundle
  • Click on the "Current bundle (PEM file)" link.
  • Save the cacert.pem file to your desired location.

2. Configure php.ini:

  • Open the php.ini file for your PHP installation.
  • Add the following lines to the end of the file:
curl.cainfo = [Path to cacert.pem]
openssl.cafile = [Path to cacert.pem]

3. Restart PHP-FPM:

  • Restart PHP-FPM or your web server (such as Apache httpd) to apply the changes.

4. Optional:

  • If you have self-signed certificates that need to be accepted, open the cacert.pem bundle in a text editor and append them to the end of the file.

The above is the detailed content of How to Fix \"Certificate Verify Failed\" Errors When Sending TLS Emails with Laravel?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn