curlterminalssl-certificateclient-certificates

How can I set the certificates in CURL


In order to get a successful response I am using curl --cacert <path of ca.pem> ... but how can i set the path of ca.pem in a configuration file in mac in order to not specify the path of the certificate every time, and i can directly use curl ...


Solution

  • On your system you can set environment variables to point to these files.

    Try:

    export SSL_CERT_FILE=/path/to/ca.pem
    

    There is also SSL_CERT_DIR environment variable to specify the directory containing certificates.

    You can add this to your .bashrc or .bash_profile file to make this permanent.

    This can be changed at compile time with curl by passing --with-ca-path=DIRECTORY when building curl but I'd recommend leaving it as is.

    Better yet, find out what CA path/file your OS and/or OpenSSL are using and add the relevant certificate there. I have no idea where they live on Mac but you should have a directory of trusted CA certs which curl is using for verification (probably somewhere in /etc).