I need to add a .pem cert file to my default CA cert bundle but I don't know where the default CA Cert bundle is kept.

I need to append my new .pem file to this default bundle. I'd rather do that than specify my own location using --capath

cURL clearly knows where to look but I don't see any cURL commands that reveal the location. Is there a command that will reveal this location? How can I find it?

According to cURL:
Add the CA cert for your server to the existing default CA cert bundle. The default path of the CA bundle used can be changed by running configure with the --with-ca-bundle option pointing out the path of your choice.



Running curl with strace might give you a clue.

strace curl https://www.google.com |& grep open

Lots of output, but right near the end I see:

open("/etc/ssl/certs/578d5c04.0", O_RDONLY) = 4

which is where my certificates are stored.

  • 2
    +1 for showing me about strace! – Robert Dundon Nov 28 '17 at 19:55
  • strace not available on macOS, apparently. The "equivalent" dtruss told me "dtrace: failed to initialize dtrace: DTrace requires additional privileges". So I used sudo with it. To which it replied "dtrace: failed to execute curl: dtrace cannot control executables signed with restricted entitlements". Not very helpful. – L S Dec 1 '17 at 17:23

There should be a program 'curl-config' in curl's 'bin/', i.e. where the 'curl' binary resides.

./curl-config --ca

gives the ca bundle install path.

I just did a whatis curl-config: "Get information about a libcurl installation" so I guess it will only be available if libcurl was installed, which I presume is standard though.

  • 1
    I had to install a package on Ubuntu to run this (you will be shown a list of available options if it's not installed), but using this command led me to the right place! – Robert Dundon Nov 28 '17 at 20:34
  • 2
    The curl-config program isn't available with all versions of the program or installations. For example, some admins may not understand the purpose of the program and not install it because they think it's only a build configuration tool. Further, if the user that needs the program isn't the admin of a system they can't install it. I have access to two systems, one doesn't have this program, the other gives no output for curl-config --ca. – L S Dec 1 '17 at 17:13
  • I prefer this answer to the accepted one - using strace to find config information shouldn't be necessary. – Ken Williams Dec 28 '17 at 18:35

I found an easy way: use the --cacert with a wrong file name, the output will show the path.


~$ curl --cacert non_existing_file https://www.google.com
curl: (77) error setting certificate verify locations:
  CAfile: non_existing_file
  CApath: /etc/ssl/certs
  • I thought this looked like a good solution. However, curl gave me the "77" error, but not the additional information. – L S Dec 1 '17 at 17:26
  • @L S try adding verbose flag: -v or --verbose – Chananel P Dec 3 '17 at 14:30

you could download the CA Root Certificates bundle from haxx.se who are the creators of curl. then just append your certificate in their .pem and refer to it when using curl with the --cacert option


-v with https in the URL.

$ curl -v https://google.com
* Rebuilt URL to: https://google.com/
* timeout on name lookup is not supported
*   Trying
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to google.com ( port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   *CAfile: C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt*
  • Nope. It didn't show anything like that for me. In fact, I compared the output of that with another run adding the -k option to see whether there's a difference. There was no difference. – L S Dec 1 '17 at 17:31
  • @LS do you have https in your URL? – Philip Rego Dec 2 '17 at 18:09

The default CA bundle location is OS dependent. On RHEL5, it is located in /etc/pki/tls/certs/ca-bundle.pem. On other flavors of Linux or non-linux OSes, it may be in a different location.

  • So I guess I just search for that file then... – Slinky Mar 7 '13 at 14:21
  • 2
    Another idea: # strings /usr/lib64/libcurl.so.3 | egrep '^/' /etc/pki/tls/certs/ca-bundle.crt – offby1 Aug 30 '13 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.