Java 添加自签名证书而不提示用户是/否
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24532103/
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
Add Self Signed Certificate without promting Yes/No from User
提问by Arun Kumar
Using some batch file, I want to add the untrusted self signed certificate within Java Keystore.
使用一些批处理文件,我想在 Java Keystore 中添加不受信任的自签名证书。
Command is
命令是
%JAVA_HOME%/bin/keytool -import -v -trustcacerts -alias server-alias
-file server.cer -keystore cacerts.jks -keypass changeit -storepass changeit
After running above command, the screen promts for Trust of certificate using Y/N.
运行上述命令后,屏幕提示使用 Y/N 的证书信任。
Trust this certificate? [no]:
But I don't want to provide Y/N here.
但我不想在这里提供 Y/N。
Is there a way to complete the import using a single command or some additional import switch if any?
有没有办法使用单个命令或一些额外的导入开关来完成导入(如果有)?
采纳答案by Arun Kumar
The option -noprompt
doesn't prompt the input Y/N from a user and assumes yes
.
该选项-noprompt
不会提示用户输入 Y/N 并假定yes
.
More details can found by running command keytool -importcert -help
on terminal.
通过keytool -importcert -help
在终端上运行命令可以找到更多详细信息。
回答by Carlos
As such, keytool is most likely looking for "yes" in your locale ("si" in this case).
因此,keytool 很可能在您的语言环境中寻找“是”(在本例中为“si”)。