Print out X509Certificate's properties : X509Certificate « Security « Java Tutorial






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

public class MainClass {
  public static void main(String args[]) throws Exception {
    FileInputStream fr = new FileInputStream("sdo.cer");
    CertificateFactory cf = CertificateFactory.getInstance("X509");
    X509Certificate c = (X509Certificate) cf.generateCertificate(fr);
    System.out.println("\tCertificate for: " + c.getSubjectDN());
    System.out.println("\tCertificate issued by: " + c.getIssuerDN());
    System.out.println("\tThe certificate is valid from " + c.getNotBefore() + " to "
        + c.getNotAfter());
    System.out.println("\tCertificate SN# " + c.getSerialNumber());
    System.out.println("\tGenerated with " + c.getSigAlgName());
  }
}








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