简体   繁体   English

无法将证书导入 cacerts

[英]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 中的证书

  1. Run command prompt as Administrator以管理员身份运行命令提示符
  2. cd C:\\Program Files\\Java\\jdk1.6.0_45\\jre\\bin cd C:\\Program Files\\Java\\jdk1.6.0_45\\jre\\bin
  3. keytool -import -trustcacerts -file "certpath\\certname.cer" -alias "cert_alias" -keystore "%JAVA_HOME%"/jre/lib/security/cacerts keytool -import -trustcacerts -file "certpath\\certname.cer" -alias "cert_alias" -keystore "%JAVA_HOME%"/jre/lib/security/cacerts
  4. To view certificate keytool -list -keystore "%JAVA_HOME%"/jre/lib/security/cacerts -alias cert_alias查看证书 keytool -list -keystore "%JAVA_HOME%"/jre/lib/security/cacerts -alias cert_alias

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.

相关问题 无法将.p12证书导入到cacerts - Unable to import .p12 certificate to cacerts Keytool无法导入证书 - Keytool unable to import certificate 为什么向 cacerts 添加证书还不够? - Why adding a certificate to cacerts is not enough? 如何检查证书是否在默认的 cacerts 中 - How to check a Certificate is in default cacerts 向仍然“无法找到请求目标的有效证书路径”的证书添加证书 - Added certificate to cacerts still “unable to find valid certification path to requested target” 将 certificate.pfx 导入 cacerts,但仍然收到“PKIX...无法找到到请求目标的有效证书路径”错误。 做什么? - imported a certificate.pfx into cacerts and still getting "PKIX...unable to find valid certification path to requested target" error. What do? 将证书导入 cacerts 时出现权限错误 - Permission error when importing certificate to cacerts PKIX路径构建失败,但证书是cacerts - PKIX path building failed, but the certificate is in cacerts 如何在Openshift中将证书添加到Java CA证书存储中(证书)? - How add a Certificate to the Java CA Certificate Store in Openshift (cacerts)? 是否可以将cacerts的所有内容导入jssecacerts文件? - Is it possible to import all contents of cacerts into a jssecacerts file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM