Search code examples
certificateopenssl

How to find out the path for OpenSSL trusted certificates?


How can I find out where my OpenSSL installation is looking for installed (trusted) certificates?

It is sometimes /etc/ssl/cert, but I have a new system and it is not working with this path.


Solution

  • This C snippet, compiled against OpenSSL, will tell you:

    #include <stdlib.h>
    #include <stdio.h>
    #include <openssl/x509.h>
    
    int main()
    {
        const char *dir;
    
        dir = getenv(X509_get_default_cert_dir_env());
    
        if (!dir)
            dir = X509_get_default_cert_dir();
    
        puts(dir);
    
        return 0;
    }