Skip to content

Error message for missing --cacert file is obtuse #19583

@wezm

Description

@wezm

I did this

I had a bit of a PEBKAC moment running a command like:

curl \
    --fail-with-body \
    --cacert cert/selfsigned.crt \
    --user "$(< auth )" \
    -O \
    "https://example.com/data/some-file"

The output was:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0   0     0   0     0     0     0  --:--:-- --:--:-- --:--:--     0
curl: (77) error adding trust anchors from file: cert/selfsigned.crt

The problem turned out to be that the cert/selfsigned.crt file was missing, which is clearly my fault. However I spent 15 minutes searching the web for answers before finally realising my mistake.

I expected the following

If the file argument to --cacert does not exist then an error like this is shown:

curl: cannot open '/tmp/hellox'
curl: try 'curl --help' for more information
curl: (26) Failed to open/read local data from file/application

(this is the error message for when the argument to -T, --upload-file does not exist)

curl/libcurl version

curl 8.17.0 (x86_64-pc-linux-gnu) libcurl/8.17.0 OpenSSL/3.6.0 zlib/1.3.1 brotli/1.1.0 zstd/1.5.7 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.1 nghttp2/1.68.0 nghttp3/1.12.0 mit-krb5/1.21.3
Release-Date: 2025-11-05
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd

operating system

Linux arch-torrent 6.16.10-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 02 Oct 2025 19:26:36 +0000 x86_64 GNU/Linux

Arch Linux

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions