Java tutorial
//package com.java2s; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.util.ArrayList; public class Main { /** * parse a certificate file into ArrayList of certificates */ public static ArrayList<Certificate> readCertificate(File f) throws CertificateException { ArrayList<Certificate> certs = new ArrayList<Certificate>(); CertificateFactory cf = CertificateFactory.getInstance("X.509"); BufferedInputStream in; try { in = new BufferedInputStream(new FileInputStream(f)); while (in.available() > 0) { Certificate cert = cf.generateCertificate(in); certs.add(cert); } in.close(); return certs; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } }