在做微信開發時候,請求為你接口報錯:
解決方案:
1 下載cacert
https://curl.haxx.se/ca/cacert.pem
2 修改 php.ini , 並重啟
curl.cainfo="真實路徑/cacert.pem"
注意: 開啟 php_curl php_openssl 擴展,
如果是用php curl() 方法 的話。可以 清除ssl證書校驗
<?php // 創建curl資源 $ch = curl_init(); // 設置url curl_setopt($ch, CURLOPT_URL, "https://www.test.com"); // 將Transfer作為字符串返回 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 關閉SSL驗證 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // 執行並輸出 $output = curl_exec($ch); // 查看錯誤 $error = curl_error($ch); echo $error; // 釋放curl資源 curl_close($ch);