首先,我們從這個地址摸到 cacert.pem
文件:https://curl.haxx.se/docs/caextract.html
在 PHP 的配置文件 php.ini
中我們可以搜索 curl.cainfo
並通過填寫正確的路徑指向使得 Composer、CURL 能夠正常請求
不過還有一個全局的更合理的方式,通過該鏈接:https://curl.haxx.se/docs/sslcerts.html
在其中搜索 CURL_CA_BUNDLE
我們可以得知:
If you're using the curl command line tool on Windows, curl will search for a CA cert file named "curl-ca-bundle.crt" in these directories and in this order:
1. application's directory
2. current working directory
3. Windows System directory (e.g. C:\windows\system32)
4. Windows Directory (e.g. C:\windows)
5. all directories along %PATH%
如果您在 Windows 中使用 curl 命令行工具,curl 將在以下目錄中按如下順序搜索名爲 curl-ca-bundle.crt 的 CA 證書文件:
1. 應用程序目錄
2. 當前執行目錄
3. C:\Windows\System32
4. C:\Windows
5. 環境變量 %PATH% 中的所有路徑
簡單來說,我們其實不用去設置一些相關參數,直接將 cacert.pem
文件重命名爲 curl-ca-bundle.crt
並扔到 C:\Windows
或 C:\Windows\System32
就行了。