Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to import certificate to cacerts

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.

like image 660
Neha Shukla Avatar asked May 28 '14 06:05

Neha Shukla


People also ask

How do I know if a certificate is added to cacerts?

You can inspect (list) certificates in your cacert keystroke using the java keytool. keytool has to be in your path, or can be found in the bin directory of your Java Installation (e.g. C:/Program Files (x86)/Java/jre1.


2 Answers

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

like image 157
Quincy Avatar answered Oct 19 '22 01:10

Quincy


If you are using OpenJDK then the path for cacerts will not be available in

"%JAVA_HOME%"/jre/lib/security/cacerts

it will be available in path

"%JAVA_HOME%"/lib/security/cacerts

like image 20
Raghav2650 Avatar answered Oct 19 '22 03:10

Raghav2650