Java 将证书导入 cacerts 时出现权限错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19186817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 14:53:41  来源:igfitidea点击:

Permission error when importing certificate to cacerts

javaauthenticationkeytool

提问by user2847458

I need to import a certificate for some maven repositories into the global keystore. The certificate file is named maven.crt so the command I am running is

我需要将某些 Maven 存储库的证书导入全局密钥库。证书文件名为 maven.crt 所以我运行的命令是

keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts -trustcacerts -alias maven -file maven.crt

It asks me for password and then if I trust the certificate to which I answer yes This is the final output

它要求我输入密码,然后我是否信任我回答是的证书 这是最终输出

Certificate was added to keystore
keytool error: java.io.FileNotFoundException: /usr/java/jdk1.7.0_40/bin/java/jre/lib/security/cacerts (Not a directory)

I ran this command as root so I don't know why I am receiving permissions error here.

我以 root 身份运行此命令,所以我不知道为什么我在这里收到权限错误。

采纳答案by Ernestas Kardzys

Your path is wrong. cacerts file is in jdk_directory/jre/lib/security.

你的路径是错误的。cacerts 文件位于 jdk_directory/jre/lib/security 中。

Try this instead:

试试这个:

keytool -import -keystore /usr/java/jdk1.7.0_40/jre/lib/security/cacerts -trustcacerts -alias maven -file maven.crt