运行时配置

这些函数的行为受 php.ini 中的设置影响。

cURL 配置选项
名字 默认 可修改范围 更新日志
curl.cainfo NULL PHP_INI_SYSTEM 自 PHP 5.3.7. 起有效
有关 PHP_INI_* 样式的更多详情与定义,见 配置可被设定范围

这是配置指令的简短说明。

curl.cainfo string

CURLOPT_CAINFO 选项的一个默认值。这个值必须是一个绝对路径。

User Contributed Notes

knuklus at gmail dot com 17-Sep-2021 06:33
cURL error 60: SSL certificate problem: unable to get local issuer certificate

This problem can occur when developing locally on windows. I am using windows 10 (x64)

In order to fix the error, I downloaded cacert.pem from https://curl.haxx.se/docs/caextract.html

Set the following value for in php.ini

curl.cainfo = "C: \ php-8.0.7 \ extras \ ssl \ cacert.pem"
ajith at pavanathara dot com 04-Sep-2020 07:02
I was editing wrong php.ini file in last comment.

Even though loaded configuration path was showing as "D:\wamp64\bin\apache\apache2.4.37\bin\php.ini" inside phpinfo() of WAMP Server, It was actually loading "D:\wamp64\bin\apache\apache2.4.37\bin\phpForApache.ini"

Once I set both the variables inside phpForApache.ini, details are displayed in phpinfo() and error has gone without extra coding line.
ajith at pavanathara dot com 04-Sep-2020 05:36
cURL error 60: SSL certificate problem: unable to get local issuer certificate

This local development error comes when curl.cainfo variable is not set correctly.

I faced this issue in PHP Version 7.3.1

In order to fix the error, I downloaded cacert.pem from https://curl.haxx.se/docs/caextract.html

Set the following paths in php.ini

curl.cainfo="D:\wamp64\bin\php\php7.3.1\extras\ssl\cacert.pem"
openssl.cafile="D:\wamp64\bin\php\php7.3.1\extras\ssl\cacert.pem"

Even after adding the paths and restart Apache, Inside phpinfo(), both the paths were showing blank.

The error will go only if we set via php code of the project.

Example code worked for me :-

$guzzle = new \GuzzleHttp\Client(['verify' => 'D:\wamp64\bin\php\php7.3.1\extras\ssl\cacert.pem']);
ASchmidt at Anamera dot net 12-May-2019 10:34
As of PHP 7.2 (Win 64) this directive, will NOT show in the phpinfo() even though it's set.

(In comparison, an openssl.cafile directive will show, if it's set to the exact same path).
PHP8中文手册 站长在线 整理 版权归PHP文档组所有