PHP使用file_get_contents()
读取HTTPS的时候报了如下的警告:
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in ….
Warning: file_get_contents(): Failed to enable crypto in….
Warning: file_get_contents(https:….
解决方案
把SSL证书验证关闭即可,代码示例如下:
<?php
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$response = file_get_contents("https://translate.google.cn/",
false,
stream_context_create($arrContextOptions)
);
echo $response;
?>
转载请注明:悠然品鉴 » Warning: file_get_contents(): SSL operation failed with code 1的解决方案