1 Java program reads the certificate from the certificate File import java. io. *; import java. security. cert. *; public class PrintCert {public static void main (String args []) throws Exception {CertificateFactory cf = CertificateFactory. getInstance ("X.509"); FileInputStream in = new FileInputStream ("my. cer "); Certificate c = cf. generateCertificate (in); in. close (); String s = c. toString (); // display the certificate FileOutputStream fout = new FileOutputStream ("tmp.txt"); BufferedWriter out = new BufferedWriter (new OutputStreamWriter (fout); out. write (s, 0, s. length (); out. close () ;}2 Java program directly reads the certificate from the keystore import java. io. *; import java. security. *; import java. security. cert. certificate; public class PrintCert2 {public static void main (String args []) throws Exception {String pass = "080302"; String alias = "mykey"; String name = ". keystore "; FileInputStream in = new FileInputStream (name); KeyStore ks = KeyStore. getInstance ("JKS"); ks. load (in, pass. toCharArray (); Certificate c = ks. getCertificate (alias); in. close (); System. out. println (c. toString () ;}} 3 the Java program displays the specified certificate information (full name/Public Key/Signature, etc.) import java. io. *; import java. security. *; import java. security. cert. *; import java. math. *; public class ShowCertInfo {public static void main (String args []) throws Exception {CertificateFactory cf = CertificateFactory. getInstance ("X.509"); FileInputStream in = new FileInputStream ("my. cer "); java. security. cert. certificate c = cf. generateCertificate (in); in. close (); X509Certificate t = (X509Certificate) c; System. out. println ("version" + t. getVersion (); System. out. println ("Serial Number" + t. getSerialNumber (). toString (16); System. out. println ("Full name" + t. getSubjectDN (); System. out. println ("issuer's full name n" + t. getIssuerDN (); System. out. println ("validity period start date" + t. getNotBefore (); System. out. println ("validity period ends on" + t. getNotAfter (); System. out. println ("signature algorithm" + t. getSigAlgName (); byte [] sig = t. getSignature (); System. out. println ("signature n" + new BigInteger (sig ). toString (16); PublicKey pk = t. getPublicKey (); byte [] pkenc = pk. getEncoded (); System. out. println ("Public Key"); for (int I = 0; I <div = ""> System. out. print (pkenc [I] + ",");}}}