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






Importing a Certificate from a File

   

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);
  }
}    

   
    
    
  








Related examples in the same category

1.Signature Test
2.Specify the keystore of certificates using the javax.net.ssl.keyStore system property:
3.Retrieving a Certificate from a Key Store
4.Adding a Certificate to a Key Store
5.Creating a Certification Path
6.Listing the Most-Trusted Certificate Authorities (CA) in a Key Store
7.Validating a Certification Path using the most-trusted CAs in the JDK's cacerts file.
8.Retrieving the Certification Path of an SSL Server
9.Getting the Subject and Issuer Distinguished Names of an X509 Certificate
10.Creates a CertStore from the contents of a file-system directory.