首页 > 代码库 > java-pfx文件转换成16进制内容

java-pfx文件转换成16进制内容

public static void main(String[] args) throws Exception {        String path = "D://111.pfx";        InputStream in = new FileInputStream(new File(path));        ByteArrayOutputStream out = new ByteArrayOutputStream();        KeyStore keyStore = KeyStore.getInstance("PKCS12");        keyStore.load(in,"111".toCharArray());        keyStore.store(out, "111".toCharArray());        BASE64Encoder b = new BASE64Encoder();        System.out.println(b.encode(out.toByteArray()));    }

这里如果知道pfx里的alias还可以取到私钥和证书。

结果

MIIJIgIBAzCCCNwGCSqGSIb3DQEHAaCCCM0EggjJMIIIxTCCA1IGCSqGSIb3DQEHAaCCA0MEggM/MIIDOzCCAzcGCyqGSIb3DQEMCgECoIICtjCCArIwHAYKKoZIhvcNAQwBAzAOBAhIpqQrmbCG+QICB9AEggKQahOSv1h6dmpTiK61Ja5VRktfTSx5nG4sL/FDck2W501J28w3/wgTClAsQIlJDUhmvGiRpp+4/H3MV6Pyd150odom0EgwNLhPyCgNDpZZXN79yihTQDTIR9AKivOA8GJousKaeBwxT4Vjs4c2ZPXtxy11zSffsW+dQ/vWORUjfAvNyBW+MxwSlyNQXC45bfmfnr0VNBqwwf2vvz12zr4hqpiIvAud/yNlWplghWC0IVWSUId1WMVyj07ZcUTp2P+zGxw/2UJEyYadtt2xSn1SHM4d8gfFpL5oTbL1Nbh1sTWf00clum7VJkJItgq9S/NaVcsJESm0NeF1Z8p2OmzNQuo4mREkVxLzkh3bE7FXX8HNoMDTGZNZnfRK5xs4jEkSsQjZfuYhg+1eeVwCDauF+HA7JhNhsvkByUG6OCGo4vmeKRYEuBxINEY8qrVKS7pEhfJTYwjuGqHVfQ1bESz9rIwgQK1BxjfFh88JErazDJw2UC6yTU0g0jDflUYMe2MP2rWhynx3Hz9a0a8/XiEOctytv4Y+crulOE+QJYqT6en7QQSjvi1W5BBMzcLpSfjIhj9yRqidaQT/4aU2yVQbUsORRykSnJkGBqznMtrJiHrCORxn9b50MOsj0ksmmrDfpBO5js1n3YzkvoxB0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