X509Certificate: getSerialNumber() : X509Certificate « java.security.cert « Java by API






X509Certificate: getSerialNumber()

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

   
    
  








Related examples in the same category

1.X509Certificate: getIssuerDN()
2.X509Certificate: getNotBefore()
3.X509Certificate: getSigAlgName()
4.X509Certificate: getSubjectDN()