使用Keytool工具生成证书Keystore和证书签名请求文件
2017-07-21 17:00
711 查看
内容概览:
keytool的几个常用的命令。
1.创建证书
2.查看证书库
3.导出证书文件
4.导入证书的信息
5.查看证书信息
6.删除密钥库中的条目
7.修改证书条目的口令
————————————————————————————–
预备知识:
keytool的概念
SUN公司提供了制作证书的工具keytool。
在JDK 1.4以后的版本中都包含了这一工具,它的位置为\bin\keytool.exe。
————————————————————————————–
主要内容:
1.创建证书
Cmd代码
keytool -genkeypair -alias “test1” -keyalg “RSA” -keystore “test.keystore”
说明:
密钥库密码为testtest
证书条目密码为testtest1,若别名为test2则密码为testtest2
这样为个不乱
功能:
创建一个别名为test1的证书条目,该条目存放在名为test.keystore的密钥库中,若test.keystore密钥库不存在则创建。
参数说明:
-genkeypair:生成一对非对称密钥;
-alias:指定密钥对的别名,该别名是公开的;
-keyalg:指定加密算法,本例中的采用通用的RAS加密算法;
-keystore:密钥库的路径及名称,不指定的话,默认在操作系统的用户目录下生成一个”.keystore”的文件
注意:
1.“名字与姓氏”应该是域名,若输成了姓名,和真正运行的时候域名不符,会出问题;
2.再次输入密码,第一次输入的是密钥库(keystore)的密码,第二次输入的是证书条目的密码
3.这里所说的证书库和密钥库是等同的(个人观点)
为了测试需要,这里再创建两个别名为test2和test3的证书条目在test.keystore密钥库中,代码如下:
Cmd代码
keytool -genkeypair -alias “test2” -keyalg “RSA” -keystore “test.keystore”
keytool -genkeypair -alias “test3” -keyalg “RSA” -keystore “test.keystore”
2.查看证书库
Cmd代码
keytool -list -keystore test.keystore
功能:
查看名为test.keystore的证书库中的证书条目
3.导出到证书文件
Cmd代码
keytool -export -alias test1 -file test.crt -keystore test.keystore
功能:
将名为test.keystore的证书库中别名为test1的证书条目导出到证书文件test.crt中
4.导入证书的信息
Cmd代码
keytool -import -keystore test_cacerts -file test.crt
功能:
将证书文件test.crt导入到名为test_cacerts的证书库中,
5.查看证书信息
Cmd代码
keytool -printcert -file “test.crt”
功能:
查看证书文件test.crt的信息
6.删除密钥库中的条目
删除前查看密钥库test.keysote中的证书条目
Cmd代码
keytool -list -keystore test.keystore
删除密钥库test.keystore中别名为test2的证书条目
Cmd代码
keytool -delete -keystore test.keystore -alias test2
删除后查看密钥库test.keystore中的证书条目
Cmd代码
keytool -list -keystore test.keystore
7.修改证书条目的口令
交互的方式
Cmd代码
keytool -keypasswd -alias test1 -keystore test.keystore
功能:
将密钥库test.keystore中别名为test1的证书条目的密码修改为testtesttest1
非交互方式
Cmd代码
keytool -keypasswd -alias test1 -keypass testtesttest1 -new testtest1 -storepass testtest -keystore test.keystore
功能:
将密钥库test.keystore中别名为test1的证书条目的密码修改为testtest1
keytool的几个常用的命令。
1.创建证书
2.查看证书库
3.导出证书文件
4.导入证书的信息
5.查看证书信息
6.删除密钥库中的条目
7.修改证书条目的口令
————————————————————————————–
预备知识:
keytool的概念
SUN公司提供了制作证书的工具keytool。
在JDK 1.4以后的版本中都包含了这一工具,它的位置为\bin\keytool.exe。
————————————————————————————–
主要内容:
1.创建证书
Cmd代码
keytool -genkeypair -alias “test1” -keyalg “RSA” -keystore “test.keystore”
说明:
密钥库密码为testtest
证书条目密码为testtest1,若别名为test2则密码为testtest2
这样为个不乱
功能:
创建一个别名为test1的证书条目,该条目存放在名为test.keystore的密钥库中,若test.keystore密钥库不存在则创建。
参数说明:
-genkeypair:生成一对非对称密钥;
-alias:指定密钥对的别名,该别名是公开的;
-keyalg:指定加密算法,本例中的采用通用的RAS加密算法;
-keystore:密钥库的路径及名称,不指定的话,默认在操作系统的用户目录下生成一个”.keystore”的文件
注意:
1.“名字与姓氏”应该是域名,若输成了姓名,和真正运行的时候域名不符,会出问题;
2.再次输入密码,第一次输入的是密钥库(keystore)的密码,第二次输入的是证书条目的密码
3.这里所说的证书库和密钥库是等同的(个人观点)
为了测试需要,这里再创建两个别名为test2和test3的证书条目在test.keystore密钥库中,代码如下:
Cmd代码
keytool -genkeypair -alias “test2” -keyalg “RSA” -keystore “test.keystore”
keytool -genkeypair -alias “test3” -keyalg “RSA” -keystore “test.keystore”
2.查看证书库
Cmd代码
keytool -list -keystore test.keystore
功能:
查看名为test.keystore的证书库中的证书条目
3.导出到证书文件
Cmd代码
keytool -export -alias test1 -file test.crt -keystore test.keystore
功能:
将名为test.keystore的证书库中别名为test1的证书条目导出到证书文件test.crt中
4.导入证书的信息
Cmd代码
keytool -import -keystore test_cacerts -file test.crt
功能:
将证书文件test.crt导入到名为test_cacerts的证书库中,
5.查看证书信息
Cmd代码
keytool -printcert -file “test.crt”
功能:
查看证书文件test.crt的信息
6.删除密钥库中的条目
删除前查看密钥库test.keysote中的证书条目
Cmd代码
keytool -list -keystore test.keystore
删除密钥库test.keystore中别名为test2的证书条目
Cmd代码
keytool -delete -keystore test.keystore -alias test2
删除后查看密钥库test.keystore中的证书条目
Cmd代码
keytool -list -keystore test.keystore
7.修改证书条目的口令
交互的方式
Cmd代码
keytool -keypasswd -alias test1 -keystore test.keystore
功能:
将密钥库test.keystore中别名为test1的证书条目的密码修改为testtesttest1
非交互方式
Cmd代码
keytool -keypasswd -alias test1 -keypass testtesttest1 -new testtest1 -storepass testtest -keystore test.keystore
功能:
将密钥库test.keystore中别名为test1的证书条目的密码修改为testtest1
相关文章推荐
- 使用Keytool工具生成证书Keystore和证书签名请求文件
- 如何使用Keytool工具生成证书Keystore和证书签名请求文件?
- 使用java keytool证书工具生成安卓发布的证书 .keystore文件 步骤xiangjie
- 使用Keytool工具生成证书及签名完整步骤
- Android程序签名详解、打包,分别使用keytool工具和Android Studio生成数字证书
- ActiveMQ SSL应用之二 使用keytool工具生成密钥和证书文件
- 使用keytool工具生成自签名证书
- eclipse签名使用的key文件(android生成keystore)
- 使用keytool生成公钥、私钥、证书并且读取出来,使用私钥签名jar并验证(转)
- 使用keytool和openssl工具生成SSL双向认证密钥对和证书库
- -------------【keytool jarsigner工具的使用】Android 使用JDK1.7的工具 进行APK文件的签名,以及keystore文件的使用
- Nginx 生成证书签名请求文件
- 使用jdk自带的keytool工具生成数字证书过程
- 用keytool生成一个自签名证书,并导出到文件
- 使用keytool生成ssl密钥文件keystore和truststore
- keytool工具生成自签名证书并且通过浏览器导入证书
- .apk 应用签名文件(.keystore)的生成 --- 证书
- Java使用keytool工具导出RSA密钥证书及导出公钥文件
- 【keytool jarsigner工具的使用】Android 使用JDK1.7的工具 进行APK文件的签名,以及keystore文件的使用
- 用keytool工具生成签名文件与获取摘要信息