《JDK学习》使用JDK的keytool生成p12证书
1 2 3 4 5 6
|
#可以不切换目录 #echo %JAVA_HOME% #cd %JAVA_HOME%bin
#生成tomatocc.keystore文件 keytool -genkeypair -alias serverkey -keyalg RSA -keysize 2048 -validity 3650 -keystore tomatocc.keystore
|
参数说明
1 2 3 4 5 6 7 8
|
storepass keystore 文件存储密码 keypass 私钥加解密密码 alias 实体别名(包括证书私钥) dname 证书个人信息 keyalt 采用公钥算法,默认是DSA keysize 密钥长度(DSA算法对应的默认算法是sha1withDSA,不支持2048长度,此时需指定RSA) validity 有效期 keystore 指定keystore文件
|
1 2 3 4 5 6 7 8 9 10 11 12
|
2. 查看keystore详情 keytool -v -list -keystore tomatocc.keystore
3. 证书导入导出 #导出tomatocc.cer文件 keytool -exportcert -keystore tomatocc.keystore -file tomatocc.cer -alias serverkey
#证书导入到密钥库:client_trust.keystore文件 keytool -importcert -keystore client_trust.keystore -file tomatocc.cer -alias client_trust_server -noprompt
#将.cer格式的证书转换为p12证书,tomatocc.p12文件 keytool -importkeystore -srckeystore tomatocc.keystore -destkeystore tomatocc.p12 -srcalias serverkey -destalias serverkey -srcstoretype jks -deststoretype pkcs12 -noprompt
|
近期评论