6

I need to add a trusted certificate into cacerts on one of my servers.

I can see that it goes under $JAVA_HOME/jre/lib/security/ from other questions

But I also have a second cacerts file, two locations are:

C:\Program Files\Java\jdk1.8.0_92\jre\lib\security

C:\Program Files\Java\jre1.8.0_92\lib\security

Up to now, I've been adding any certificates into both, which is probably not correct. Is it definitely the first option, and if so, what's the use of the second one?

achAmháin
  • 4,176
  • 4
  • 17
  • 40

2 Answers2

4

The JDK and JRE are different pieces of software, although they are related. Typically the JDK bundle will include the JRE (Java run-time system) plus some other tools. You can use either to run your code, so long as you don't need JDK functionality at runtime (e.g., you're not compiling code on-the-fly). You should put your certificates into whichever (JDK or JRE) you are actually using to run your application.

Kevin Boone
  • 4,092
  • 1
  • 11
  • 15
  • Ah ok - the `so long as you don't need JDK functionality at runtime` part was something I didn't know regarding the certs. Thanks. – achAmháin Oct 02 '17 at 14:29
1

The easiest way to determine this is to check your environment variables and see which one your JAVA_HOME variable is pointing to, a quick Google search will tell you how to do this if you don't know already. If I had to guess you should probably be changing the cacerts file in your JDK, but its always good to actually check and make sure.

On a side note, if you are having trouble with with your Java cacerts file, take a look at the code here (not my code): https://www.cs.ucsb.edu/~pconrad/cs56/examples/ldap/SimpleQuery/InstallCert.java

I have been able to use it to solve alot of certificate issues in the past.

ledigiacomo
  • 55
  • 1
  • 10
  • See https://stackoverflow.com/questions/1906445/what-is-the-difference-between-jdk-and-jre?rq=1 for a more extended discussion on the difference between the JDK and JRE – ledigiacomo Oct 02 '17 at 14:22
  • Thanks. I do know the difference, and also how to check my environment variables. I just wasn't sure which folder as I mentioned to put the certificate into. – achAmháin Oct 02 '17 at 14:30