Php download https picture error Failed to enable crypto

file_get_contents download a https image with the following error

Warning: file_get_contents (): Failed to enable crypto

failed to open stream: operation failed in

openssl extension and fopen url have been opened in php.ini

check that it is turned on correctly in phpinfo

    $arrContextOptions=array(
        "ssl"=>array(
            "verify_peer"=>false,
            "verify_peer_name"=>false,
        ),
    ); 
    // return file_get_contents($url);
    return file_get_contents($url, false, stream_context_create($arrContextOptions));
    

using this code is also invalid, but this error is still reported

Php
Apr.02,2022

Certificate error. Try specifying the certificate, download the certificate in the program accessible directory

$options = [
    "ssl" => [
        'cafile' => "/path/to/file/cacert.pem", // cacert.pem
    ]
];
return file_get_contents($url, false, stream_context_create($options));
Menu