• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java keystore problem  RSS feed

 
Ranch Hand
Posts: 278
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

I'm having a problem with a Java keystore I'm trying to use. Whenever my application tries to send a message, which is encrypted using the keystore, it throws an exception and fails to send the message. The application loads the keystore from a JKS file in the classpath root of a JAR file. Here's the Java code that does this:

But when it tries to send a message, an exception is thrown:

Here's the last part of the stack trace:

Another application uses a copy of the exact same JAR (and thus, has the exact same keystore) and works perfectly fine!! I tried adding the keystore to Java's trust store ($JAVA_HOME/jre/lib/security/cacerts), but that didn't help either. Both applications use the same JDK. Any pointers? Thanks!
 
Michael Angstadt
Ranch Hand
Posts: 278
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Update:

I tried using a copy of the cacerts keystore in place of my application's keystore (I imported my application's keystore into the cacerts keystore). This threw a different exception when trying to get the private key:

Stacktrace:

Java code:

With the other (working) application, I would get this error a lot if I used a keystore generated in Windows (we use Linux in production). Resolving this simply involved using a copy of the keystore that was generated in Linux. This can't be the issue here, however, because I used the Linux copy of the keystore when importing it into cacerts.

In the application configuration, if I change the password to something I know is wrong, I get a different exception that says "Password verification failed", so the password I'm using must be correct. Similarly, if I change the keystore filename or the alias to something wrong, I get different exception, so these values must be correct as well.

Sorry if I'm getting any terminology wrong, I don't have much experience working with certificates!
 
Michael Angstadt
Ranch Hand
Posts: 278
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nevermind, the problem had to do with the way the application was configured. Thanks for letting me vent anyway.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!