![](/img/trans.png)
[英]PHP cURL (SSL certificate problem: self signed certificate in certificate chain)
[英]PHP cURL error: SSL certificate problem: self signed certificate
長話短說,我不得不在我的 Mac 上重新安裝 php 7.4。 我有一個 php webapp,它命中了 .NET API。 Prior to the reinstall of php, I was able to hit a locally running version of my API at https://localhost:5001 using cURL in php but now I get a response code of 0 with this error:
Curl error: SSL certificate problem: self signed certificate
如果我將相同的 php 代碼指向我的生產 API,一切正常。 我能夠使用 Postman 成功地擊中 API 的本地版本。
我嘗試了這篇文章中接受的答案,但即使在重新啟動 apache 和我的電腦后它對我也不起作用。 我嘗試了php.ini
和運行時方法,但都沒有解決我的問題。
您應該將自簽名證書的公鑰 append 保存到 cacert.pem 文件中。 然后,此處提出的任一解決方案(在 php.ini 中設置curl.cainfo
或使用CURLOPT_CAINFO
明確指定 cacert.pem 文件的路徑)都應該可以正常工作。
添加公鑰時,請確保尊重 cacert.pem 文件的格式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.