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);
相關文章
相關標籤/搜索