php curl ssl

//设置PEM证书,pfx证书转pem方法:openssl pkcs12 -in 2000000501.pfx  -out 2000000501.pem
$cacert = ROOT_DIR."config/paykey/weixinss.pem";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
// 从证书中检查SSL加密算法是否存在
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
//设置证书信息
curl_setopt($ch, CURLOPT_SSLCERT, $cacert);
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, '1218651401');
curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'PEM');
//设置CA
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
// 对认证证书来源的检查,0表示阻止对证书的合法性的检查。1需要设置CURLOPT_CAINFO
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
//curl_setopt($ch, CURLOPT_CAINFO, $this->caFile);
$result = curl_exec($ch);

 

posted @ 2014-07-02 19:58  欧麦噶地  阅读(504)  评论(0编辑  收藏  举报