How to Resolve \'stream_socket_enable_crypto(): SSL Operation Failed with Code 1\' Error Using PHP 5.6 and GoDaddy SSL?

Linda Hamilton
Release: 2024-10-19 10:06:30
Original
364 people have browsed it

How to Resolve

stream_socket_enable_crypto() Error: SSL Operation Failed with Code 1

When using PHP 5.6 and a GoDaddy SSL certificate on Amazon EC2 Linux, an error may arise during email sending with Mailgun or other SMTP services over SSL:

stream_socket_enable_crypto(): SSL operation failed with code 1.
OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Copy after login

Root Cause

This error occurs due to stricter SSL certificate verification introduced in PHP 5.6. By default, PHP will check the domain name in the URL against the domain name in the certificate. Since GoDaddy's SSL certificate is a wildcard certificate, it does not match the specific domain name of your server.

Solution

There are two ways to resolve this issue:

Option 1: Disable Certificate Verification

<code class="php">'stream' => [
    'ssl' => [
        'allow_self_signed' => true,
        'verify_peer' => false,
        'verify_peer_name' => false,
    ],
],</code>
Copy after login

Caution: Disabling certificate verification can compromise the security of your application. It is recommended to use Option 2 instead, or upgrade to PHP 7.2 or later.

Option 2: Upgrade PHP

PHP versions 7.2 and later include a fix for this issue. Upgrading your PHP version will resolve this error and maintain the security of your application.

The above is the detailed content of How to Resolve \'stream_socket_enable_crypto(): SSL Operation Failed with Code 1\' Error Using PHP 5.6 and GoDaddy SSL?. For more information, please follow other related articles on the PHP Chinese website!

source:php
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!