Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I import an existing Java keystore (.jks) file into a Java installation?

Tags:

java

keystore

jks

So, I am having trouble with LDAP. I have an integration test case that hopefully will work out, but it is currently running into LDAPS security issues with the SSL handshake.

I am able to connect to the LDAPS with Apache Directory Studio, and it has downloaded the keystore into a file "permanent.jks".

That's ok, but I want my integration test, which resides in Eclipse using a JRE, to be able to connect to the LDAP server using this keystore.

How can I take this keystore and import it into the JRE for its own use?

like image 255
MetroidFan2002 Avatar asked Oct 18 '11 19:10

MetroidFan2002


People also ask

How do I import a keystore?

The command "importkeystore" is used to import an entire keystore into another keystore, which means all entries from the source keystore, including keys and certificates, are all imported to the destination keystore within a single command. You can use this command to import entries from a different type of keystore.

Is the .JKS file keystore file?

keystore: it's usually implied that it's a JKS file, since JKS is the default keystore type in the Sun/Oracle Java security provider. Not everyone uses the . jks extension for JKS files, because it's implied as the default. I'd recommend using the extension, just to remember which type to specify.


1 Answers

Ok, so here was my process:

keytool -list -v -keystore permanent.jks - got me the alias.

keytool -export -alias alias_name -file certificate_name -keystore permanent.jks - got me the certificate to import.

Then I could import it with the keytool:

keytool -import -alias alias_name -file certificate_name -keystore keystore location

As @Christian Bongiorno says the alias can't already exist in your keystore.

like image 84
MetroidFan2002 Avatar answered Sep 23 '22 17:09

MetroidFan2002