private void printCertFromStream(InputStream in,PrintStream out) throws Exception {
  Collection<? extends Certificate> c=null;
  try {
    c=cf.generateCertificates(in);
  }
 catch (  CertificateException ce) {
    throw new Exception(rb.getString("Failed.to.parse.input"),ce);
  }
  if (c.isEmpty()) {
    throw new Exception(rb.getString("Empty.input"));
  }
  Certificate[] certs=c.toArray(new Certificate[c.size()]);
  for (int i=0; i < certs.length; i++) {
    X509Certificate x509Cert=null;
    try {
      x509Cert=(X509Certificate)certs[i];
    }
 catch (    ClassCastException cce) {
      throw new Exception(rb.getString("Not.X.509.certificate"));
    }
    if (certs.length > 1) {
      MessageFormat form=new MessageFormat(rb.getString("Certificate.i.1."));
      Object[] source={new Integer(i + 1)};
      out.println(form.format(source));
    }
    if (rfc)     dumpCert(x509Cert,out);
 else     printX509Cert(x509Cert,out);
    if (i < (certs.length - 1)) {
      out.println();
    }
  }
}

private void printCertFromStream ( InputStream in , PrintStream out ) throws Exception { Collection < ? extends Certificate > c = null ; try { c = cf . generateCertificates ( in ) ; } catch ( CertificateException ce ) { throw new Exception ( rb . getString ( "Failed.to.parse.input" ) , ce ) ; } if ( c . isEmpty ( ) ) { throw new Exception ( rb . getString ( "Empty.input" ) ) ; } Certificate [ ] certs = c . toArray ( new Certificate [ c . size ( ) ] ) ; for ( int i = 0 ; i < certs . length ; i ++ ) { X509Certificate x509Cert = null ; try { x509Cert = ( X509Certificate ) certs [ i ] ; } catch ( ClassCastException cce ) { throw new Exception ( rb . getString ( "Not.X.509.certificate" ) ) ; } if ( certs . length > 1 ) { MessageFormat form = new MessageFormat ( rb . getString ( "Certificate.i.1." ) ) ; Object [ ] source = { new Integer ( i + 1 ) } ; out . println ( form . format ( source ) ) ; } if ( rfc ) dumpCert ( x509Cert , out ) ; else printX509Cert ( x509Cert , out ) ; if ( i < ( certs . length - 1 ) ) { out . println ( ) ; } } }
reads a certificate ( or certificate chain ) and prints its contents in a human readable format .
