Importing a Certificate from a File : CertificateFactory « Security « Java Tutorial






import java.io.File;
import java.io.FileInputStream;
import java.security.cert.CertificateFactory;

public class Main {
  public static void main(String[] argv) throws Exception {

    FileInputStream is = new FileInputStream(new File("your"));

    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    java.security.cert.Certificate cert = cf.generateCertificate(is);
  }
}








36.8.CertificateFactory
36.8.1.Using the CertificateFactory Class
36.8.2.reading multiple certificates with a CertificateFactory.
36.8.3.Creating a Certification Path
36.8.4.Importing a Certificate from a File