java解析pfx
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()); String b64 = new String(Base64.encode(out.toByteArray())); System.out.println(b64); Enumeration<String> aliases = keyStore.aliases(); String enumeration = null; while (true) { try { enumeration = aliases.nextElement(); System.out.println(enumeration); } catch (NoSuchElementException e) { System.out.println("读取完毕"); break; } } java.security.cert.Certificate cert = keyStore.getCertificate(enumeration); System.out.println(cert.toString()); PrivateKey privateKey = (PrivateKey) keyStore.getKey(enumeration, "111".toCharArray()); System.out.println(privateKey); }
如果有使用请标明来源:http://www.cnblogs.com/duwenlei/