1. 生成.keystore
keystore证书相关知识说明:他人博客
自签名证书和CA证书详解:他人博客
2. .keystore转.cer
keytool -exportcert -keystore server.keystore -rfc -file server1.cer -alias tomcat -storepass 123456
3. .keystore转.pfx
这里我没有找到更简便的方法, 找到的大佬希望指点一下。
我这里用代码转换:
// .keystore转.pfx
public class Text {
public static final String PFX_KEYSTORE_FILE = "server.pfx";
public static final String KEYSTORE_PASSWORD = "123456";
public static final String JKS_KEYSTORE_FILE = "server.keystore";
public static void main(String[] args) {
coverToPfx();
}
public static void coverTokeyStore() {
try {
KeyStore inputKeyStore = KeyStore.getInstance("PKCS12");
FileInputStream fis = new FileInputStream(PFX_KEYSTORE_FILE);
char[] nPassword = null;
if (