PHP:CURLOPT_SSLCERT的路径

时间:2017-02-27 03:29:33

标签: php curl

如果$path是本地路径,那就有用了。

$path = /var/www/apiclient_cert.pem
curl_setopt($ch,CURLOPT_SSLCERT, $path);

但如果$path是一个网址,则无效,例如http://myfile.com/www/apiclient_cert.pem

如果$ path是一个网址,为什么它不起作用?

function post( $strXml) {

$url='https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 


curl_setopt($ch, CURLOPT_SSLCERT,'/var/www/html/hongbao/apiclient_cert.pem'); //Line-#1
curl_setopt($ch, CURLOPT_SSLKEY,'/var/www/html/hongbao/apiclient_key.pem');
curl_setopt($ch, CURLOPT_CAINFO, '/var/www/html/hongbao/rootca.pem');


curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $strXml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$res = curl_exec($ch);
curl_close($ch);
return $res;
}

0 个答案:

没有答案