]> git.ipfire.org Git - thirdparty/curl.git/commit
curl: add options for safe/no CA bundle search (Windows)
authorViktor Szakats <commit@vsz.me>
Sun, 18 Aug 2024 07:51:49 +0000 (09:51 +0200)
committerViktor Szakats <commit@vsz.me>
Sun, 22 Sep 2024 16:17:25 +0000 (18:17 +0200)
commit22652a5a4cb6a4cc1c0f4ff3ebc4f9768f6663cd
tree8563d08dd5feeed2d681fd7fe29c268642b222cb
parent668584a94f59341bdc1b0a08add72af9379f48b0
curl: add options for safe/no CA bundle search (Windows)

Add `CURL_CA_SEARCH_SAFE` build-time option to enable CA bundle search
in the `curl` tool directory. The lookup method was already used to find
`.curlrc` and `_curlrc` (on Windows). On Windows it overrides the unsafe
default `SearchPath()` method.

Enable with:
- cmake: `-DCURL_CA_SEARCH_SAFE=ON`
- autotools: `--enable-ca-search-safe`
- raw: `CPPFLAGS=-DCURL_CA_SEARCH_SAFE`

On Windows, before this patch the whole `PATH` was searched for
a CA bundle. `PATH` may contain unwanted or world-writable locations,
including the current directory. Searching them all is convenient to
pick up any CA bundle, but not secure.

The Muldersoft curl distro implements such CA search via a custom
patch for Windows:
https://github.com/lordmulder/cURL-build-win32/blob/cd652d4792c177c98b08b4309d3cac2b8dbbf9b0/patch/curl_tool_doswin.diff#L50

MSYS2/mingw-w64 distro has also been rolling a patch solving this:
https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-curl/0001-Make-cURL-relocatable.patch
https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-curl/pathtools.c

Also add option to fully disable Windows CA search:
- cmake: `-DCURL_DISABLE_CA_SEARCH=ON`
- autotools: `--disable-ca-search`
- raw: `CPPFLAGS=-DCURL_DISABLE_CA_SEARCH`.

Both options are considered EXPERIMENTAL, with possible incompatible
changes or even (partial) removal in the future, depending on feedback.

An alternative, secure option is to embed the CA bundle into the binary.

Safe search can be extended to other platforms if necessary or useful,
by using `_NSGetExecutablePath()` (macOS),
`/proc/self/exe` (Linux/Cygwin), or `argv[0]`.

Closes #14582
14 files changed:
.github/workflows/windows.yml
CMakeLists.txt
configure.ac
docs/CURL-DISABLE.md
docs/SSLCERTS.md
docs/cmdline-opts/cacert.md
lib/curl_config.h.cmake
src/tool_doswin.c
src/tool_doswin.h
src/tool_operate.c
src/tool_parsecfg.c
src/tool_util.c
src/tool_util.h
tests/server/disabled.c