Tag Archives: file_get_contents(): SSL operation failed with code 1

[Solved] file_get_contents(): SSL operation failed with code 1

Error content
file_get_contents(): SSL operation failed with code 1.OpenSSL Error messages:\nerror:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

This is related to the local environment. Whether SSL authentication is enabled
solution: modify the configuration or code

$stream_opts = [
    "ssl" => [
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ]
];  
 
$response = file_get_contents($url, false, stream_context_create($stream_opts));