本文介绍了如何使用java密钥库工具自动生成密钥库?没有用户互动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to automate keystore generation using the Java keystore tool. The command I am using is :

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

但是在此命令之后,用户需要按如下方式输入某些输入:

But after this command, user is required to enter certain inputs as follows:

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

而不是用户输入这些值,有没有办法在没有用户交互的情况下提供这些值,无论是在命令内还是通过脚本?

Instead of the user entering these values , is there any way of providing these values without user interaction ,either within the command or through a script?

谢谢

推荐答案

试试这个:

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

这篇关于如何使用java密钥库工具自动生成密钥库?没有用户互动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-26 01:53