keytool用法

来源:互联网 发布:软件测试黑盒 编辑:程序博客网 时间:2024/05/17 23:57

下列的终端命令需要先进入.android文件夹,然后再输入。

要不然会报“keytool 错误: java.lang.Exception: 密钥库文件不存在: debug.keystore”的错误,如下图:


1、创建证书:

keytool -genkey -alias ca -keyalg RSA -keystore hehe.keystore 

注:ca是密钥对的别名,是公开的,可修改为自己的别名。

RSA是加密算法,默认是DSA。

hehe.keystore是key的名字,可以修改为xxx.keystore。


2、查看证书:

keytool -list -keystore hehe.keystore 


注:上图中,别名ca是可见的。

3、导出证书:

keytool -export -alias ca -file hehe.crt -keystore hehe.keystore


4、查看导出的证书

keytool -printcert -file hehe.crt


4、导入证书

keytool -import -keystore hehe.keystore  -file hehe.crt 


5、删除证书条目(删除别名):

keytool -delete -keystore hehe.keystore -alias ca


6、修改证书条目,交互式(修改密码)

keytool -keypasswd -alias ca -keystore hehe.keystore 

7、修改证书条目,非交互式(修改密码):

keytool -keypasswd -alias ca -keypass qing1016 -new 654321 -storepass qing1016 -keystore hehe.keystore 

注:qing1016是老密码,654321是新密码。

8、修改别名:

keytool -changealias -keystore hehe.keystore -alias mykey -destalias androiddebugkey

注:mykey是当前的别名,androiddebugkey是修改后的别名。

1 0
原创粉丝点击