public static X509Certificate[] loadCertificates(InputStream is) throws CryptoException {
  byte[] certsBytes=null;
  try {
    certsBytes=ReadUtil.readFully(is);
    certsBytes=fixCommonInputCertProblems(certsBytes);
    is=new ByteArrayInputStream(certsBytes);
    CertificateFactory cf=CertificateFactory.getInstance(X509_CERT_TYPE,BOUNCY_CASTLE.jce());
    Collection<? extends Certificate> certs=cf.generateCertificates(is);
    ArrayList<X509Certificate> loadedCerts=new ArrayList<X509Certificate>();
    for (Iterator<? extends Certificate> itr=certs.iterator(); itr.hasNext(); ) {
      X509Certificate cert=(X509Certificate)itr.next();
      if (cert != null) {
        loadedCerts.add(cert);
      }
    }
    return loadedCerts.toArray(new X509Certificate[loadedCerts.size()]);
  }
 catch (  IOException ex) {
    throw new CryptoException(res.getString("NoLoadCertificate.exception.message"),ex);
  }
catch (  NoSuchProviderException e) {
    throw new CryptoException(res.getString("NoLoadCertificate.exception.message"),e);
  }
catch (  CertificateException ex) {
    try {
      return loadCertificatesPkiPath(new ByteArrayInputStream(certsBytes));
    }
 catch (    CryptoException ex2) {
      throw new CryptoException(res.getString("NoLoadCertificate.exception.message"),ex);
    }
  }
 finally {
    IOUtils.closeQuietly(is);
  }
}

public static X509Certificate [ ] loadCertificates ( InputStream is ) throws CryptoException { byte [ ] certsBytes = null ; try { certsBytes = ReadUtil . readFully ( is ) ; certsBytes = fixCommonInputCertProblems ( certsBytes ) ; is = new ByteArrayInputStream ( certsBytes ) ; CertificateFactory cf = CertificateFactory . getInstance ( X509_CERT_TYPE , BOUNCY_CASTLE . jce ( ) ) ; Collection < ? extends Certificate > certs = cf . generateCertificates ( is ) ; ArrayList < X509Certificate > loadedCerts = new ArrayList < X509Certificate > ( ) ; for ( Iterator < ? extends Certificate > itr = certs . iterator ( ) ; itr . hasNext ( ) ; ) { X509Certificate cert = ( X509Certificate ) itr . next ( ) ; if ( cert != null ) { loadedCerts . add ( cert ) ; } } return loadedCerts . toArray ( new X509Certificate [ loadedCerts . size ( ) ] ) ; } catch ( IOException ex ) { throw new CryptoException ( res . getString ( "NoLoadCertificate.exception.message" ) , ex ) ; } catch ( NoSuchProviderException e ) { throw new CryptoException ( res . getString ( "NoLoadCertificate.exception.message" ) , e ) ; } catch ( CertificateException ex ) { try { return loadCertificatesPkiPath ( new ByteArrayInputStream ( certsBytes ) ) ; } catch ( CryptoException ex2 ) { throw new CryptoException ( res . getString ( "NoLoadCertificate.exception.message" ) , ex ) ; } } finally { IOUtils . closeQuietly ( is ) ; } }
load one or more certificates from the specified stream .
