How can the OpenSSL error message "certificate verify failed" be resolved in PHP?
The "certificate verify failed" error in OpenSSL occurs when PHP is unable to verify the SSL certificate of the server it is trying to connect to. This can happen if the certificate is self-signed or if the certificate authority is not recognized. To resolve this issue, you can disable certificate verification in your PHP code, although this is not recommended for production environments due to security concerns.
// Disable certificate verification
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
]);
// Use the stream context when making the HTTPS request
$response = file_get_contents('https://example.com', false, $context);