The X509 certificate is the digital certificate. Here is the sample code to read the X509 certificate
Code:
public class PrintCRT {
public static void main(String args[]) {
try {
FileInputStream fr = new FileInputStream("X509.cer");
CertificateFactory cf =
CertificateFactory.getInstance("X509");
X509Certificate crt = (X509Certificate)
cf.generateCertificate(fr);
System.out.println("Read certificate:");
System.out.println("\tCertificate for: " +
crt.getSubjectDN());
System.out.println("\tCertificate issued by: " +
crt.getIssuerDN());
System.out.println("\tCertificate is valid from " +
crt.getNotBefore() + " to " + c.getNotAfter());
System.out.println("\tCertificate SN# " +
crt.getSerialNumber());
System.out.println("\tGenerated with " +
crt.getSigAlgName());
} catch (Exception e) {
e.printStackTrace();
}
}
Bookmarks