使用keytool工具常用证书转换

2,041 阅读1分钟

使用keytool工具常用证书转换

p12 转 jks keytool -importkeystore -srckeystore keystore.p12 -srcstoretype PKCS12 -deststoretype JKS -destkeystore keystore.jks

jks 转 p12 keytool -importkeystore -srckeystore keystore.jks -srcstoretype JKS -deststoretype PKCS12 -destkeystore keystore.p12

jks导出crt证书 keytool -export -alias test -keystore trust.jks -storepass 123456 -file test.cer

crt证书导入jks keytool -import -v -alias test -file test.cer -keystore trust.jks -storepass 123456 -noprompt

去除pem格式的key的密码(输出的密码不输入即可) openssl rsa -in crt1.key -out crt2.key

合并pem格式输出pfx(p12) openssl pkcs12 -export -inkey test.key -in cert2.crt -out test.pfx

指定intermedian和CA openssl pkcs12 -export -out mypkcs12.pfx -inkey my.private.key -in mycert.crt -certfile intermediate.crt -CAfile ca.crt

pfx 转 pem openssl pkcs12 -in test.pfx -out test.pem -nodes

pem 转 key openssl rsa -in test.pem -out test.key

pem 转 crt openssl x509 -in test.pem -out test.crt

cert 转 pem openssl x509 -in test.cer -out test.pem -outform PEM

pem 转 der openssl x509 -in test.pem -inform PEM -out test.der -outform DER

der 转 pem openssl x509 -in test.cer -inform DER -out test.pem -outform PEM