public X509SSLSocketFactory(X509Store creds)
     throws InternalException, NoSuchAlgorithmException, KeyManagementException, KeyStoreException,
         UnrecoverableKeyException {
   super(
       "TLS",
       creds.getKeystore(),
       X509Store.PASSWORD,
       null,
       null,
       null,
       SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
 }
  /**
   * Return a Collection of all CRLs found in the X509Store's that are matching the crlSelect
   * criteriums.
   *
   * @param crlSelect a {@link X509CRLStoreSelector} object that will be used to select the CRLs
   * @param crlStores a List containing only {@link org.ripple.bouncycastle.x509.X509Store
   *     X509Store} objects. These are used to search for CRLs
   * @return a Collection of all found {@link java.security.cert.X509CRL X509CRL} objects. May be
   *     empty but never <code>null</code>.
   */
  private final Collection findCRLs(X509CRLStoreSelector crlSelect, List crlStores)
      throws AnnotatedException {
    Set crls = new HashSet();
    Iterator iter = crlStores.iterator();

    AnnotatedException lastException = null;
    boolean foundValidStore = false;

    while (iter.hasNext()) {
      Object obj = iter.next();

      if (obj instanceof X509Store) {
        X509Store store = (X509Store) obj;

        try {
          crls.addAll(store.getMatches(crlSelect));
          foundValidStore = true;
        } catch (StoreException e) {
          lastException = new AnnotatedException("Exception searching in X.509 CRL store.", e);
        }
      } else {
        CertStore store = (CertStore) obj;

        try {
          crls.addAll(store.getCRLs(crlSelect));
          foundValidStore = true;
        } catch (CertStoreException e) {
          lastException = new AnnotatedException("Exception searching in X.509 CRL store.", e);
        }
      }
    }
    if (!foundValidStore && lastException != null) {
      throw lastException;
    }
    return crls;
  }