报错file_get_contents(): SSL operation failed with code 1

报错内容

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

这和本地环境有关,是否开启了ssl验证。

解决方法

一: file_get_contents 增加参数传递指定

亲测有效

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

二:公共文件通过 stream_context_get_default 函数指定 

亲测有效

三:修改php.ini配置文件

测试后,未解决实际问题。。

打开php.ini文件,extension=php_openssl.dll去掉前面的分号,allow_url_include = off改为allow_url_include = On,然后重启服务就可以了。

 

posted on   爱吃柠檬不加糖  阅读(1201)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· AI Agent开发,如何调用三方的API Function,是通过提示词来发起调用的吗

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示