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);

 

php curl ssl,布布扣,bubuko.com

php curl ssl

上一篇:Delphi用QJSON解析JSON格式的数据


下一篇:[转]WCF:如何将net.tcp协议寄宿到IIS