9

I'm slightly confused about cacerts formats. An application I use recently had to upgrade it's cacerts file. The original cacerts file was pk12 format (I assume, it's binary), while the new format is clearly pem. I can use either cacert, but when I suggested someone having trouble with authentication upgrade to the new cacert he gets complaints because it is not a pk12 format.

What file format should cacert's be? can it be either format? Does something configure/define which format it should expect?

dsollen
  • 6,046
  • 6
  • 43
  • 84

2 Answers2

7

On any normal Oracle Java installation (before Java 9, this is an old answer), cacerts should be a proprietary, binary, JKS key store type. I've checked this against 1.8.0_20. From 9 onwards it is replaced by a binary PKCS#12 key store (or rather, trusted certificate store).

To be sure you may use file cacerts on GNU systems (Linux). If you have something different you may have a different JRE or the cacerts file is replaced.

You can manage the contents of cacerts using the keytool command delivered with the JDK.

Note that the key store that contains the private key(s) for authentication usually is a PKCS#12 key store.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
  • 2
    Java 9 will convert to PKCS#12 key stores as default according to the JSR. On my system however the current development version from the start of April (still?) uses a Java key store for `cacerts`. – Maarten Bodewes May 04 '16 at 10:00
  • why is that in windows cacerts file is not shown any extension towards end of the file name ? – rinilnath Dec 30 '22 at 13:17
4

Perhaps this might help others with similar searches: I was trying to find the default list of trusted certificate authorities for the Java Runtime Environment because we wanted to install an SSL certificate into Tomcat. Had to finally remove oracle site from google searches and found this method to parse the binary file for the list. Good luck finding it at Oracle.com!

http://www.herongyang.com/PKI/HTTPS-Java-Default-Trusted-KeyStore-File-cacerts.html

<java jre directory>\bin\keytool -list -keystore cacerts -storepass changeit

Or you could do it the easy way by clicking the "system" tab when checking the java control panel - security - certificates

PBSLuvr
  • 51
  • 4