Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpClient] CurlHttpClient throws Undefined constant CURLOPT_PINNEDPUBLICKEY #42061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sirian opened this issue Jul 11, 2021 · 1 comment
Closed

Comments

@sirian
Copy link
Contributor

sirian commented Jul 11, 2021

Symfony version(s) affected: 5.3, 5.4

Description
Some CURL constants could be not defined depending on libcurl version.
Thus private CurlHttpClient::validateExtraCurlOptions throws Undefined constant "CURLOPT_PINNEDPUBLICKEY" even though user code doesn't use this constant.

\CURLOPT_PINNEDPUBLICKEY => 'peer_fingerprint',

For example CURLOPT_PINNEDPUBLICKEY requires libcurl 7.39.0

How to reproduce

You could try Centos 7 with remi PHP.

PHP 8.0.8
cURL support => enabled
cURL Information => 7.29.0
$client = new CurlHttpClient();
$response = $client->request('GET', 'https://download.geonames.org/export/dump/alternatenames/RU.zip', [
    'extra' => [
        'curl' => [
            CURLOPT_MAX_RECV_SPEED_LARGE => 1024
        ]
    ]
]);
var_dump(strlen($response->getContent()));

Possible Solution
Check that constant is defined(...) or add polyfill

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jul 11, 2021

It's very hard to know what can and cannot be defined.
Please submit a PR adding the defined() checks if you have a setup that allows producing such an error.
There are already similar checks in the source, you can take inspiration from them.

@OskarStark OskarStark changed the title [BUG] [http-client] CurlHttpClient throws Undefined constant "CURLOPT_PINNEDPUBLICKEY" [HttpClient] CurlHttpClient throws Undefined constant "CURLOPT_PINNEDPUBLICKEY" Jul 13, 2021
@OskarStark OskarStark changed the title [HttpClient] CurlHttpClient throws Undefined constant "CURLOPT_PINNEDPUBLICKEY" [HttpClient] CurlHttpClient throws Undefined constant CURLOPT_PINNEDPUBLICKEY Jul 13, 2021
nicolas-grekas added a commit that referenced this issue Dec 22, 2021
…grekas)

This PR was merged into the 5.3 branch.

Discussion
----------

[HttpClient] fix checking for recent curl consts

| Q             | A
| ------------- | ---
| Branch?       | 5.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #42061
| License       | MIT
| Doc PR        | -

Commits
-------

0d477e9 [HttpClient] fix checking for recent curl consts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants