Use X.509 certificate : X509Certificate « Security « Java Tutorial






import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;

public class MainClass {

  public static void main(String args[]) throws Exception {
    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    FileInputStream in = new FileInputStream(args[0]);
    Certificate c = cf.generateCertificate(in);
    in.close();
    String s = c.toString();
    FileOutputStream fout = new FileOutputStream("tmp.txt");
    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fout));
    out.write(s, 0, s.length());
    out.close();

  }

}








36.47.X509Certificate
36.47.1.Print out X509Certificate's properties
36.47.2.Creating a Self-Signed Version 1 Certificate
36.47.3.Creating a Self-Signed Version 3 Certificate
36.47.4.Use X.509 certificate
36.47.5.Display properties of X509 Certificate
36.47.6.Generate cert path for X.509