java-在php上运行keytool

我需要一个PHP脚本来生成带有密钥库的jks.
我应该使用什么命令?

exec()或system()?

我的代码:

exec("keytool -genkey -alias 1800 -keyalg RSA -keysize 2048 -validity 365 -keystore 1800.jks -keypass brsacquiro -storepass brsacquiro 2>&1", $return_var);

foreach($return_var as $word)
echo "$word<br>";

我得到结果:

What is your first and last name?
[Unknown]: What is the name of your organizational unit?
[Unknown]: What is the name of your organization?
[Unknown]: 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=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct?

我连续得到十本书.我需要回答那里列出的问题.
在此列表的末尾我得到了错误:

keytool error: java.lang.RuntimeException: Too many retries, program terminated

如果我在cmd中编写此命令,则一切正常.

解决方法:

不管使用什么,exec()或system().使用此示例并将ClientName,OrganizationUnit等替换为您的值

keytool -genkey -noprompt \
 -alias alias1 \
 -dname "CN=ClientName, OU=OrganizationUnit, O=Organization, L=Locality, S=State, C=CountryCode" \
 -keystore keystore \
 -storepass password \
 -keypass password
上一篇:java-没有共同的Mule密码套件


下一篇:Keystore was tampered with, or password was incorrect