Description
Symfony version(s) affected: 5.2.6
Description
I get the following warning and notice:
User Warning: Configure the "curl.cainfo", "openssl.cafile" or "openssl.capath" php.ini setting to enable the CurlHttpClient
User Notice: Upgrade the curl extension or run "composer require amphp/http-client" to perform async HTTP operations, including full HTTP/2 support
I am on Windows and don't have these options set in my php.ini
, but I have set cafile
How to reproduce
- on Windows, enable the curl PHP extension. Don't set any options in
php.ini
. - create a symfony app, add
symfony/http-client
- get a valid certificate in PEM format
- edit
app/config/packages/framework.yaml
, sethttp_client
->default_options
->cafile: <path to PEM file>
- inject
HttpClientInterface
, perform a request
Possible Solution
I guess this check in HttpClient::create
is faulty:
if ('\\' !== \DIRECTORY_SEPARATOR || ini_get('curl.cainfo') || ini_get('openssl.cafile') || ini_get('openssl.capath'))
Extending it with isset($defaultOptions['cafile']) || isset($defaultOptions['capath'])
fixes both log messages.
However, CurlHttpClient
can also be used if you set cafile
or capath
on options for scoped clients, but these options aren't available in the factory.
Why is this check present anyway? CurlHttpClient
works great on Windows without any of these options.
Additional context