如何使用java keystore工具自动化密钥库生成? 无用户交互

我正在尝试使用Java密钥库工具自动化密钥库生成。 我正在使用的命令是:

keytool -keystore keystore -alias jetty -genkey -keyalg RSA 

但是在这个命令之后,用户需要input如下的某些input:

 Enter keystore password: password What is your first and last name? [Unknown]: jetty.mortbay.org What is the name of your organizational unit? [Unknown]: Jetty What is the name of your organization? [Unknown]: Mort Bay Consulting Pty. Ltd. What is the name of your City or Locality? [Unknown]: What is the name of your State or Province? [Unknown]: What is the two-letter country code for this unit? [Unknown]: Is CN=jetty.mortbay.org, OU=Jetty, O=Mort Bay Consulting Pty. Ltd., L=Unknown, ST=Unknown, C=Unknown correct? [no]: yes Enter key password for <jetty> (RETURN if same as keystore password): password 

用户input这些值,而不是用户input这些值,是否有任何方式提供这些值,无需用户交互,无论是在命令或通过脚本?

谢谢

尝试这个:

 keytool -genkey -noprompt \ -alias alias1 \ -dname "CN=mqttserver.ibm.com, OU=ID, O=IBM, L=Hursley, S=Hants, C=GB" \ -keystore keystore \ -storepass password \ -keypass password 

请参阅有关命令行的完整文档或通过键入keytool而不带任何参数。

具体来说,您可能需要查看选项-storepass password -keypass password

不要忘记-noprompt,否则你会被要求inputYes或No