jssdk (Problem with reading the SSL CA cert (path? access rights?))

2017-11-10 Frank PHP

一个微信的老项目前几天报错了,jssdk接口获取不到值,原来的代码如下

private function httpGet($url) {
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_TIMEOUT, 500);
    curl_setopt($curl, CURLOPT_URL, $url);

    $res = curl_exec($curl);
    curl_close($curl);

    return $res;
  }

下载最新的demo发现多了两行,

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, true);

修改如下:

private function httpGet($url) {
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_TIMEOUT, 500);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);

    curl_setopt($curl, CURLOPT_URL, $url);

    $res = curl_exec($curl);
    curl_close($curl);

    return $res;
  }

修改之后还是空值,打开curl_error

var_dump(curl_error($curl)) ;

报错
(Problem with reading the SSL CA cert (path? access rights?))

接下来安装证书并重启php

yum reinstall openssl ca-certificates -y
#fpm 关闭
killall -9 php-fpm
#fpm启动
/usr/local/php/sbin/php-fpm

解决。

发表评论 登录

Top