使用keytool工具
J2SDK提供了keytool工具。我们可以用它来根据指定的参数创建数字证书:
1. 创建数字证书
keytool -genkey -v -alias scent -dname "CN=John,OU=MNG,O=Corp,L=Hangzhou,ST=Zhejiang,C=CN" -keyalg RSA -keysize 2048 -keypass 123456 -keystore prospectlib -storepass 123456 -storetype JCEKS -validity 900
keytool -list -rfc -keystore prospectlib -storepass 123456
keytool -list -v -alias scent -keystore prospectlib -storepass 123456
keytool -import -alias scent -file scent.cer -keystore prospectlib -storepass 123456
keytool -export -alias scent -file scent.cer -keystore prospectlib -storepass 123456
keytool -delete -alias scent -file scent.cer -keystore prospectlib -storepass 123456
keytool -printcert -v -file scent.cer
keytool -changealias -v -alias scent -destalias perfume -keystore prospectlib -storepass 123456
keytool -importkeystore -v -srckeystore prospectlib -srcstoretype JKS -srcstorepass 123456 -destkeystore intrinsic -deststoretype JKS -deststorepass 123456 -srcalias terrific prospect -destalias terrific prospect
keytool -keypasswd -alias brilliant -keystore range -storepass 123456 -keypass 123456 -new 654321
keytool -storepasswd -v -new 654321 -keystore range -storepass 123456 -storetype JKS