![file_get_contents(): SSL operation failed with code 1. OpenSSL Error message](https://imgsrc.baidu.com/forum/pic/item/d000baa1cd11728bd70549108efcc3cec3fd2cdc.png)
file_get_contents(): SSL operation failed with code 1. OpenSSL Error message
今天跑之前写的一个采集,提示错误:
file_get_contents(): SSL operation failed with code 1. OpenSSL Error message
以为是升级了PHP版本到从7.4换成7.0的原因,结果换回原来的7.4的也提示,顺便解决了一下。
在file_get_contents前面加个配置,忽略证书验证即可。主要这里是采集,没必要做证书校验。
调整后代码:
$option=array('ssl'=>array('verify_peer' => false,'verify_peer_name' => false)); $html = file_get_contents("https://www.baidu.com",false,stream_context_create($option));
![weinxin](https://imgsrc.baidu.com/forum/pic/item/6609c93d70cf3bc7149e17de9700baa1cd112a62.png)
我的微信
我的微信
微信扫一扫
评论