Windows 下关于 CURL SSL 证书的放置说明

首先,我们从这个地址摸到 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 就行了。或是将此证书安装至 计算机 内的 受信任的根证书颁发机构 也可。

评论

暂无评论