帮助文档>SSL证书 > PHP SSL operation failed with code 1. And more 错误的解决方案

PHP SSL operation failed with code 1. And more 错误的解决方案

发布时间:2021-11-06 09:16

在使用例如file_get_contents这样的函数读取https的资源的时候,遇到这个报错信息
首先确认加载了openssl模块 并且allow_url_fopen是打开状态
这种时候有两种方案

第一种

简单粗暴的跳过ssl认证

array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),
);  

$response = file_get_contents("https://maps.co.weber.ut.us/arcgis/rest/services/SDE_composite_locator/GeocodeServer/findAddressCandidates?Street=&SingleLine=3042 N 1050 W&outFields=*&outSR=102100&searchExtent=&f=json", false, stream_context_create($arrContextOptions));

echo $response; ?>

第一种方法属于比较粗暴的方法 直接放弃ssl认证,不建议这种方法。

第二种方法

1.前往ca证书下载地址下载下来证书
2.上传至服务器的php的可读目录
3.配置php.ini 中的openssl.cafile

[openssl]openssl.cafile=/***php可读目录***/cert.pem

4.重启php-fpm就可以了。

本文导读

客户热线:037125966675

客户服务中心
云产品 服务器 合 作                  Skype