Cacerts file location

Linux & MacOS

The cacerts file is a collection of trusted certificate authority (CA) certificates. It is located in the Java Runtime Environment distribution under the path:

<jre_path>/lib/security/cacerts

The extension is not specified in the file name, but the file is of JKS type. For this reason, in some cases, an explicit indication of the file type is required. ZooKeeper, for example, has a special property ssl.trustStore.type.

Installed Java implies the ability to run java in a terminal. So, we can trace where the executable file is located:

readlink -f $(which java)

The which command shows you where the link being used is. readlink reads the link and shows the original file. As a result, we get something like:

/usr/java/jdk1.8.0_111/jre/bin/java

It remains to replace /bin/java with the path to cacerts:

/usr/java/jdk1.8.0_111/jre/lib/security/cacerts

Windows

Get the location of the link:

where java

Then, we are looking for what the link points to. Notice the argument to the dir command. We need to use the path to the folder with the link, not to the link itself:

findstr java | dir /a "<path to the folder with the link from the previous command>"

We get something like:

C:\Program Files\Java\jre1.8.0_111\bin\java.exe

Replace bin\java.exe with the path to cacerts:

C:\Program Files\Java\jre1.8.0_111\lib\security\cacerts
Telegram channel

If you still have any questions, feel free to ask me in the comments under this article or write me at promark33@gmail.com.

If I saved your day, you can support me 🤝

Leave a Reply

Your email address will not be published. Required fields are marked *