Skip to content

Fix GH-25727: CURLOPT_CAINFO and CURLOPT_CAPATH do not accept null - #25834

Open
AyhamJo7 wants to merge 1 commit into
php:PHP-8.4from
AyhamJo7:fix-gh25727-curl-cainfo-capath-null
Open

AyhamJo7 wants to merge 1 commit into
php:PHP-8.4from
AyhamJo7:fix-gh25727-curl-cainfo-capath-null

Conversation

@AyhamJo7

Copy link
Copy Markdown

The quoted paragraphs were written with an LLM (disclosed as "LLM usage in GitHub comments" in CONTRIBUTING.md asks).

Fixes GH-25727. curl_setopt() converted null for CURLOPT_CAINFO and CURLOPT_CAPATH to an empty string. libcurl takes an empty string as a path, cannot load it and ends the transfer with CURLE_SSL_CACERT_BADFILE (77). So there was no way to turn off one source of CA certificates and keep verifying against the other. The two options move to the nullable string options, the same change as a8a3b99 (GH-11433) made for CURLOPT_ACCEPT_ENCODING. Values other than null are handled as before.

The test starts openssl s_server the way curl_setopt_ssl.phpt does. It verifies the server certificate through CURLOPT_CAPATH only and through CURLOPT_CAINFO only, then sets CURLOPT_CAINFO and resets both options to null, which has to make verification fail with error 60. Without the fix all three requests end with error 77. The third case is there because code that ignored null would pass the first two.

Tested on this branch with --enable-debug --enable-zts against libcurl 8.5.0 (Ubuntu 24.04) and 7.88.1 (Debian 12, the version in the report): ext/curl has 151 passed, 18 skipped and 0 failed with both. The PR targets PHP-8.4 as the lowest supported branch; the lines are the same on master.

CURLOPT_PROXY_CAINFO and CURLOPT_PROXY_CAPATH have the same limitation. They are not part of this PR because I have no HTTPS proxy test for them; I can add them if you prefer.

null was converted to an empty string, which libcurl takes as a path
and fails to load (CURLE_SSL_CACERT_BADFILE). Pass NULL to libcurl
instead, as for the other nullable string options, so that one source
of CA certificates can be turned off while the other stays in use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant