Updated on 2020-10-12
生成密钥对:
keytool -genkeypair -keystore release.p12 -storepass changeit -storetype pkcs12 -alias release -keyalg RSA -dname "cn=123" -ext "san=dns:*.example.com,ip:127.0.0.1" -validity 365
keytool -list -keystore release.p12 -storepass changeit -storetype pkcs12
导出证书:
keytool -exportcert -keystore release.p12 -storepass changeit -alias release -file release.crt -rfc
keytool -printcert -file release.crt
信任证书:
keytool -importcert -cacerts -trustcacerts -storepass changeit -alias release -file release.crt -noprompt
keytool -list -cacerts -storepass changeit
删除证书:
keytool -delete -cacerts -trustcacerts -storepass changeit -alias release
转换密钥对格式:
keytool -importkeystore ^
-srckeystore release.p12 -srcstoretype pkcs12 -srcstorepass changeit ^
-destkeystore release.jks -deststoretype jks -deststorepass changeit
导出证书:
openssl pkcs12 -in release.p12 -password pass:changeit -out release.crt -nokeys
导出私钥:
openssl pkcs12 -in release.p12 -password pass:changeit -out release.key -nocerts -nodes