Unable to import certificate to cacerts

Neha Shukla picture Neha Shukla · May 28, 2014 · Viewed 53.3k times · Source

My requirement is to import a certificate for maven repositories into the global keystore.

The certificate file is named maven-cacert.cer .

I am using following command from C:\Program Files\Java\jdk1.6.0_20\bin\ from cmd

keytool -importcert -trustcacerts -alias c:\maven-cacert.cer -file c:\maven-cacert.cer.der -keystore $JAVA_HOME\jre\lib\security\cacerts

as maven-cacert.cer file is in C directory

after pressing enter it asked to put password and after giving password it is saying like

keytool error: java.io.FileNotFoundException: $JAVA_HOME\jre\lib\security\cacerts (The system cannot find the path specified

I also tried

   keytool -importcert -trustcacerts -alias c:\maven-cacert.cer -file c:\maven- cacert.cer.der -keystore \usr\java/jdk1.6.0_20/bin/java\jre\lib\security\cacerts

but getting same output

Please help what is going wrong with my command while cacerts file is inside $JAVA_HOME\jre\lib\security\ directory.

Answer

Quincy picture Quincy · May 28, 2014

Try using "%JAVA_HOME%\jre\lib\security\cacerts"