13

In my user home directory there is a .keystore file. Whenever I do keytool -list I get:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 0 entries

However while running junit tests from Eclipse, the JVM is always referring to this keystore. How can I change this path to another keystore path, for example, C:\Users\abc123\jdk1.8.0_65\jre\lib\security\cacerts from Eclipse.

I have tried

Debug As --> Debug Configuration --> Junit --> VM arguments

-Djavax.net.ssl.trustStore="C:/Users/b91255/jdk1.8.0_65/jre/lib/security/cacerts "
-Djavax.net.ssl.trustStorePassword="changeit"

I am getting a certification chaining error. How can I ask eclipse to use C:\Users\abc123\jdk1.8.0_65\jre\lib\security\cacerts as the SSL keystore?

Stewart
  • 17,616
  • 8
  • 52
  • 80
Ashish Banker
  • 2,243
  • 3
  • 20
  • 21
  • Obviously not the best answer, but have you considered removing the empty keystore from your user home? – Aaron May 23 '17 at 09:31
  • @ Aaron : I tried after removing the empty keystore, still getting the same error – Ashish Banker May 23 '17 at 10:00
  • After reading your question again I suppose it could be a problem with your junit configuration, which certainly will not take into account your debug configuration. I don't know junit that well so I can't tell you where to look, but I suppose a file search on your project for `.keystore` might do the trick. Also, having a certification chaining error doesn't automatically mean that you're not using the correct truststore – Aaron May 23 '17 at 10:05

2 Answers2

17

in addition to @Tushar Patels answer, this is like

go to eclipse.ini file and edit:

-vmargs
-Djavax.net.ssl.trustStore="C:/Users/b91255/jdk1.8.0_65/jre/lib/security/cacerts "
-Djavax.net.ssl.trustStorePassword="changeit"
Ashish Patil
  • 4,428
  • 1
  • 15
  • 36
  • 1
    I had an interesting scenario where I had added a corporate cert to the keystore, but it (apparently?) wasn't picking up the correct keystore. Once I specified the `-vm` option, it cleared it up. It seems like it's just best to either use this or explicitly specify the trustStore so you can ensure Eclipse is using what you _think_ it's using. – Skeeterdrums Mar 11 '20 at 18:31
3

You can set this in eclipse.ini file which will be in the root of the eclipse folder.

Tushar Patel
  • 365
  • 3
  • 16