Iterator iter = findCertificates(certSelect, certStores).iterator();
Iterator iter; try { iter = findCertificates(certSelect, certStores).iterator(); } catch (CertStoreException e) { throw new CertPathValidatorException(e); }
    private final X509Certificate findIssuer(        X509Certificate cert,        List certStores)        throws CertPathValidatorException    {        Exception invalidKeyEx = null;        X509CertSelector certSelect = new X509CertSelector();        try        {            certSelect.setSubject(cert.getIssuerX500Principal().getEncoded());        }        catch (IOException ex)        {            throw new CertPathValidatorException("Issuer not found", null, null, -1);        }        Iterator iter = findCertificates(certSelect, certStores).iterator();        X509Certificate issuer = null;        while (iter.hasNext() && issuer == null)        {            issuer = (X509Certificate)iter.next();            try            {                cert.verify(issuer.getPublicKey());            }            catch (Exception ex)            {                invalidKeyEx = ex;                issuer = null;            }        }        if (issuer == null && invalidKeyEx == null)        {           throw new CertPathValidatorException("Issuer not found", null, null, -1);        }        if (issuer == null && invalidKeyEx != null)        {            throw new CertPathValidatorException("issuer found but certificate validation failed",invalidKeyEx,null,-1);        }        return issuer;    }