keytool -genkey error: Keystore file does not exist

匿名 (未验证) 提交于 2019-12-03 02:47:02

问题:

I try to create a new self certified keystore file

The command I use is:

keytool -genkey -selfcert -dname "cn=My Name, ou=Orga unit" -alias selfcertified -keypass somepass -keystore keystore.jks -storepass anotherpass -validity 365 

but I always get this annoying error:

keytool error: java.lang.Exception: Keystore file does not exist: keystore.jks 

I do not understand why I'm getting this error. The command above should create a new keystore, so why is it complaining about a non existing store?

回答1:

Generating a key pair (and a new keystore) has to be done as a separate operation to creating a self-signed certificate for that key.

i.e.

keytool -genkey -alias myKey -keystore store.jks keytool -selfcert -alias myKey -keystore store.jks 


回答2:

Run command prompt as Administrator and it will be done.



回答3:

-selfcert option was made obsolete in keytool for Java 6. Check the last section of "Changes" here: Java 6 Keytool

So for Java 6 and onwards, replace -selfcert with -certreq



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!