柔晶美网络工作室

柔晶美网络工作室,倾心于web技术的博客站点

关注我 微信公众号

您现在的位置是: 首页 > 博客日记

宝塔面板,getimagesize(): 报错提示SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL

2021-10-06 admin php  1007

以前使用getimagesize获取图片参数一直正常,今天突然报错了:

getimagesize(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL 

经查,是php的证书过期了。这种报错也在使用例如file_get_contents这样的函数读取https的资源的时候会出现。首先确认加载了openssl模块 并且allow_url_fopen是打开状态,这种时候有两种方案:

第一种 简单粗暴的跳过ssl认证

getimagesize前面加@,或者:

$arrContextOptions=array(
    "ssl"=>array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),
);  

使用时:

$response = file_get_contents("https://maps.com", false, stream_context_create($arrContextOptions));

但这种方案不推荐,最好用第二种:

1.前往ca证书下载地址下载证书:https://curl.se/docs/caextract.html

2. 编辑/etc/pki/tls/certs/ca-bundle.crt,将刚才下载的证书内容复制过来,粘贴到该文件替换。

如果是windows系统,需要放在宝塔目录/php/81/ssl/xxxx.crt文件,然后在php.ini的curl中设置绝对路径,并删除前面的分号,重启php即可。

文章评论


需要 登录 才能发表评论
热门评论
0条评论

暂时没有评论!