Failed to import certificate into cacerts

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

The certificate file is called maven-cacert.cer.

I use the 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 

how the maven-cacert.cer file is located in the C directory

after pressing enter, he asked to put the password and after providing the password he says how

 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 the same output

Please help with what happens to my team, and the cacerts is inside the $JAVA_HOME\jre\lib\security\ directory.

+6
source share
5 answers

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

+13
source

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

You also had a problem with an alias. This is a name, not a file. You need to specify "% JAVA_HOME%" because it has a space in it.

+3
source

What is your OS? If you are running Windows, can you try replacing $ JAVA_HOME% JAVA_HOME% and see how this happens?

Thanks Anui

+1
source

Use the Bellow command to import the certificate into cacerts

  • Run command prompt as administrator
  • cd C: \ Program Files \ Java \ jdk1.6.0_45 \ jre \ bin
  • keytool -import -trustcacerts -file "certpath \ certname.cer" -alias "cert_alias" -keystore "% JAVA_HOME%" / jre / lib / security / cacerts
  • To view the certificate keytool -list -keystore "% JAVA_HOME%" / jre / lib / security / cacerts -alias cert_alias
+1
source

For some reason, I think JAVA_HOME was not defined for me. I just used the full path. Running from the desktop folder, my full command is:

 "C:\Program Files\Java\jre1.8.0_77\bin\keytool" -import -alias fiddlercert -file fiddlerRoot.cer -keystore "C:\Program Files\Java\jre1.8.0_77\lib\security\cacerts" -storepass changeit 
0
source

Source: https://habr.com/ru/post/969937/


All Articles