Skip to content

ssl: support Apple SecTrust configurations#18703

Closed
icing wants to merge 7 commits into
curl:masterfrom
icing:apple-sectrust
Closed

ssl: support Apple SecTrust configurations#18703
icing wants to merge 7 commits into
curl:masterfrom
icing:apple-sectrust

Conversation

@icing

@icing icing commented Sep 24, 2025

Copy link
Copy Markdown
Contributor
  • configure/cmake support for enabling the option
  • supported in OpenSSL and GnuTLS backends
  • when configured, Apple SecTrust is the default trust store for peer verification. When one of the CURLOPT_* for adding certificates is used, that default does not apply.
  • add documentation of build options and SSL use

@github-actions github-actions Bot added cmdline tool tests CI Continuous Integration labels Sep 24, 2025
@icing icing added TLS appleOS specific to an Apple operating system and removed cmdline tool tests CI Continuous Integration labels Sep 24, 2025
@github-actions github-actions Bot added cmdline tool tests CI Continuous Integration labels Sep 24, 2025
@icing icing requested review from bagder, jay and vszakats September 24, 2025 09:54
@icing

icing commented Sep 24, 2025

Copy link
Copy Markdown
Contributor Author

This is my suggestion on how to add this feature. We could maybe extend this to mbedTLS and wolfSSL, but I was not sure it is worth it. OpenSSL(-like)+GnuTLS should be enough for the start.

The specific behaviour I designed for is:

# uses Apple SecTrust
> curl https://example.com

# uses *only* certs from file.pem
> curl --cacert file.pem https://example.com

# uses *both* certs from file.pem and SecTrust
> curl --ca-native --cacert file.pem https://example.com

This would also happen for a libcurl application. SecTrust would only be used when the applications does not configure any ca file/path/blob. What is currently not possible is:

# still uses Apple SecTrust
> curl --no-ca-native https://example.com

because I could not think of a way to decide if CURLOPT_SSL_OPTIONS flags did just omit CURLSSLOPT_NATIVE_CA because it did not matter before or if it was intentionally left out.

Comment thread lib/url.c
Comment thread docs/SSLCERTS.md Outdated
Comment thread docs/INSTALL.md Outdated
@jay

jay commented Sep 24, 2025

Copy link
Copy Markdown
Member
# still uses Apple SecTrust
> curl --no-ca-native https://example.com

because I could not think of a way to decide if CURLOPT_SSL_OPTIONS flags did just omit CURLSSLOPT_NATIVE_CA because it did not matter before or if it was intentionally left out.

That's right it only disables the option which disables passing the flag.

@jay

jay commented Sep 24, 2025

Copy link
Copy Markdown
Member

I don't know enough Apple to formally review this so I'm going to have to punt. I did take a look at it and left some comments though.

@icing icing force-pushed the apple-sectrust branch 2 times, most recently from 3efe2dc to ab78e43 Compare September 26, 2025 08:36
@bagder

bagder commented Oct 2, 2025

Copy link
Copy Markdown
Member

Hm, this gets some new CI failures we need to check first

icing added 4 commits October 3, 2025 09:26
- configure/cmake support for enabling the option
- supported in OpenSSL and GnuTLS backends
- when configured, Apple SecTrust is the default trust store
  for peer verification. When one of the CURLOPT_* for adding
  certificates is used, that default does not apply.
- add documentation of build options and SSL use
icing added 2 commits October 3, 2025 09:26
- re-add backend Schannel check to not apply default BUNDLE/PATH
- fix wording/formatting in SSLCERTS.md
- clarify fallback option in INSTALL.md
@icing icing requested a review from bagder October 3, 2025 08:06

@vszakats vszakats left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor, likely unrelated, log issue I noticed while testing, is that --doh-url seems to suppress the SSL Trust Anchors: info.

Using the -DUSE_APPLE_SECTRUST=ON dev build curl-macos-universal-clang from https://github.com/curl/curl-for-win/actions/runs/18216661900

$ CURL_CA_BUNDLE=/opt/homebrew/etc/ca-certificates/cert.pem ./curl -q --doh-url https://zero.dns0.eu/ -v https://curl.se/ --out-null

it does only say SSL certificate verified via OpenSSL..

With --doh-url <url> deleted, SSL Trust Anchors: appears as expected.

@icing

icing commented Oct 3, 2025

Copy link
Copy Markdown
Contributor Author

Good catch, @vszakats . I need to inspect the DoH code on how it tries to set ca-bundle/-path/native from the initiating transfer.

Update: but when you explicity specify a CA-Bundle, as command line options or via env var, the native CA is turned off. You need to add --ca-native to include it.

@bagder bagder closed this in eefd03c Oct 3, 2025
nono303 pushed a commit to nono303/win-build-scripts that referenced this pull request Oct 22, 2025
vszakats added a commit that referenced this pull request Nov 6, 2025
Syncing behavior with `CURL_CA_BUNDLE` and autotools.

`/etc/ssl/certs` is empty by default on macOS systems, thus no likely
auto-detection finds something there.

Follow-up to eefd03c #18703

Closes #19380
vszakats added a commit to vszakats/curl that referenced this pull request Nov 27, 2025
vszakats added a commit that referenced this pull request Nov 27, 2025
vszakats added a commit that referenced this pull request Jan 17, 2026
With the same semantics as Apple SecTrust, in both libcurl and the curl
tool, when using non-Schannel TLS backends. In practice it means that
it makes TLS work without manually or implicitly configuring a CA bundle
`.crt` file, such as `curl-ca-bundle.crt`.

To enable:
- autotools: `--enable-ca-native`
- cmake: `-DCURL_CA_NATIVE=ON`
- CPPFLAGS: `-DCURL_CA_NATIVE`

When enabled:
- enables `CURLSSLOPT_NATIVE_CA` (libcurl) / `--ca-native`
  and `--proxy-ca-native` (curl tool) options by default.
- unsafe search for an on-disk CA bundle gets disabled by default.
  Equivalent to `--disable-ca-search` with autotools,
  `-DCURL_DISABLE_CA_SEARCH=ON` with CMake.
- build-time detection of CA bundle and CA path gets disabled. As with
  Apple SecTrust. This was already the default for Windows.
- native CA can be disabled at run-time with the `--no-ca-native`
  and/or `--no-proxy-ca-native` command-line options.

Rationale: This build option:
- has a repeat and active interest from packagers and users.
- helps integrating curl with Windows for those who need this.
- it also applies to macOS: #17525
  Shipped in curl 8.17.0.
- makes it trivial to use custom certs configured on the OS.
- frees applications/packagers/users from the task of securely
  distributing, and keeping up-to-date, a CA bundle.
- frees potentially many curl tool from configuring a CA bundle manually
  to access HTTPS (and other TLS) URLs. This is traditionally difficult
  on Windows because there is no concept of a universal, protected,
  non-world-writable, location on the file system to securely store
  a CA bundle.
- allows using modern features regardless of Windows version. Some of
  these features are not supported with Schannel (e.g. HTTP/3, ECH) on
  any Windows version.
- is necessary for HTTP/3 builds, where bootstrapping a CA bundle is not
  possible with Schannel, because MultiSSL is not an option, and HTTP/3
  is not supported with Schannel.

Ref: #16181 (previous attempt)
Ref: #9348
Ref: #9350
Ref: #13111
Ref: microsoft/vcpkg#46459 (comment)
Ref: 22652a5 #14582
Ref: eefd03c #18703

Closes #18279
vszakats added a commit to vszakats/curl that referenced this pull request Jan 19, 2026
vszakats added a commit that referenced this pull request Jan 19, 2026
vszakats added a commit that referenced this pull request May 16, 2026
In AppleSecTrust or NativeCA-enabled builds, make sure override it when
setting a custom `CURLOPT_PROXY_CAINFO_BLOB`.

Reported-by: Joshua Rogers (Aisle Research)

Follow-up to 1730407 #18279
Follow-up to eefd03c #18703

Closes #21631
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
In AppleSecTrust or NativeCA-enabled builds, make sure override it when
setting a custom `CURLOPT_PROXY_CAINFO_BLOB`.

Reported-by: Joshua Rogers (Aisle Research)

Follow-up to 1730407 curl#18279
Follow-up to eefd03c curl#18703

Closes curl#21631
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

appleOS specific to an Apple operating system CI Continuous Integration cmdline tool tests TLS

Development

Successfully merging this pull request may close these issues.

5 participants