Results 1 to 2 of 2

Thread: How to read the X509 certificate in java

  1. #1
    Senior Member
    Join Date
    Oct 2012
    Posts
    236
    Blog Entries
    5

    How to read the X509 certificate in java

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

  2. #2
    Junior Member
    Join Date
    Dec 2012
    Posts
    1
    thanx for this
    i am read this very helpful post and thread
    thanx alot sir .

Similar Threads

  1. Replies: 0
    Last Post: 12-11-2012, 09:21 AM
  2. How to extract the information from the digital certificate (X509)?
    By Santhi Katuri in forum Programming languages
    Replies: 1
    Last Post: 06-06-2012, 12:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •