微信退款 curl错误 错误码58 怎么解决? 是我的证书路径不对吗


function curl_post_ssl($url, $vars,$file_cert_pem,$file_key_pem, $second = 30, $aHeader = array())
{
$ch = curl_init();
//超时时间
curl_setopt($ch, CURLOPT_TIMEOUT, $second);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//这里设置代理,如果有的话
//curl_setopt($ch,CURLOPT_PROXY, '10.206.30.98');
//curl_setopt($ch,CURLOPT_PROXYPORT, 8080);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

curl_setopt($ch,CURLOPT_HEADER,FALSE);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
//以下两种方式需选择一种

//第一种方法,cert 与 key 分别属于两个.pem文件
//默认格式为PEM,可以注释
curl_setopt($ch,CURLOPT_SSLCERTTYPE,'PEM');
// curl_setopt($ch,CURLOPT_SSLCERT,getcwd().'/cert.pem');
curl_setopt($ch,CURLOPT_SSLCERT,$file_cert_pem);
//默认格式为PEM,可以注释
curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM');
// curl_setopt($ch,CURLOPT_SSLKEY,getcwd().'/private.pem');
curl_setopt($ch,CURLOPT_SSLKEY,$file_key_pem);

curl_setopt($ch, CURLOPT_SSLCERT, dirname(__FILE__).'cert'.DIRECTORY_SEPARATOR.'apiclient_cert.pem');
curl_setopt($ch, CURLOPT_SSLKEY, dirname(__FILE__).'cert'.DIRECTORY_SEPARATOR.'apiclient_key.pem');
//第二种方式,两个文件合成一个.pem文件
// curl_setopt($ch, CURLOPT_SSLCERT, getcwd() . '/all.pem');

// if (count($aHeader) >= 1) {
// curl_setopt($ch, CURLOPT_HTTPHEADER, $aHeader);
// }


curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
$data = curl_exec($ch);
if($data){
curl_close($ch);
return $data;
}
else {
$error = curl_errno($ch);
echo "curl出错,错误码:$error"."<br>";
curl_close($ch);
return false;
}
}


a538aefca2d06bcfae82afc117b7b452.png


Vote Vote Cancel Collect Collect Cancel

<< 上一篇: 谁做过人脸检测?

>> 下一篇: laravel项目移植到linux报错