[英]Unable to import certificate to cacerts
My requirement is to import a certificate for maven repositories into the global keystore.我的要求是将 maven 存储库的证书导入全局密钥库。
The certificate file is named maven-cacert.cer.证书文件名为 maven-cacert.cer。
I am using following command from C:\Program Files\Java\jdk1.6.0_20\bin\
from cmd
我正在使用来自 cmd 的
C:\Program Files\Java\jdk1.6.0_20\bin\
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由于
maven-cacert.cer
文件位于C
目录中
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但得到相同的 output
Please help what is going wrong with my command while cacerts
file is inside $JAVA_HOME\jre\lib\security\
directory.当
cacerts
文件位于$JAVA_HOME\jre\lib\security\
目录中时,请帮助我的命令出了什么问题。
尝试使用"%JAVA_HOME%\\jre\\lib\\security\\cacerts"
keytool -importcert -trustcacerts -alias mycert -file c:\\maven-cacert.cer.der -keystore "%JAVA_HOME%"\\jre\\lib\\security\\cacerts keytool -importcert -trustcacerts -alias mycert -file c:\\maven-cacert.cer.der -keystore "%JAVA_HOME%"\\jre\\lib\\security\\cacerts
You also had a problem with alias.您也遇到了别名问题。 It's a name, not a file.
这是一个名称,而不是一个文件。 You need to quote the "%JAVA_HOME%" , because it has a space inside.
您需要引用 "%JAVA_HOME%" ,因为它里面有一个空格。
If you are using OpenJDK then the path for cacerts
will not be available in如果您使用的是 OpenJDK,则
cacerts
的路径将不可用
"%JAVA_HOME%"/jre/lib/security/cacerts
it will be available in path它将在路径中可用
"%JAVA_HOME%"/lib/security/cacerts
Use Bellow command to import the certificate in cacerts使用 Bellow 命令导入 cacerts 中的证书
For some reason, I think JAVA_HOME was not defined for me.出于某种原因,我认为 JAVA_HOME 不是为我定义的。 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
What is your OS?你的操作系统是什么? If you are on Windows, can you try replacing $JAVA_HOME with %JAVA_HOME% and see how it goes?
如果您使用的是 Windows,您可以尝试将 $JAVA_HOME 替换为 %JAVA_HOME% 并看看效果如何?
Thanks, Anuj谢谢,阿努杰
I tried with following command in cmd of windows, it has worked finally:我尝试在 windows 的 cmd 中使用以下命令,终于成功了:
"%JAVA_HOME%"\bin\keytool.exe -import -trustcacerts -alias *Certificate filename* -file *full path of certificate location ending with certificatename* -keystore "%JAVA_HOME%"\lib\security\cacerts
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.