LEN

抛错 file_get_contents(): SSL operation failed with code 1.
错误提示:PHP Warning: file_get_contents(): SSL operation fai...
扫描右侧二维码阅读全文
22
2019/10

抛错 file_get_contents(): SSL operation failed with code 1.

错误提示:

PHP 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 /data/spiderMan/test.php on line 9
PHP Warning:  file_get_contents(): Failed to enable crypto in /data/spiderMan/test.php on line 9

遇到同样的问题
解决办法:

$stream_opts = [
    "ssl" => [
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ]
];

$file = file_get_contents('https://img001.yayxcc.com/1557905908MZ2btl7Z5oyO6kcX.jpg', false, stream_context_create($stream_opts));
file_put_contents('./1.jpg', $file);
最后修改:2019 年 10 月 22 日 12 : 12 AM
如果觉得我的文章对你有用,请随意赞赏

发表评论