public static String matchCertificate(KeyStore keyStore,X509Certificate cert) throws CryptoException {
  try {
    for (Enumeration aliases=keyStore.aliases(); aliases.hasMoreElements(); ) {
      String alias=(String)aliases.nextElement();
      if (keyStore.isCertificateEntry(alias)) {
        X509Certificate compCert=X509CertUtil.convertCertificate(keyStore.getCertificate(alias));
        if (cert.equals(compCert)) {
          return alias;
        }
      }
    }
    return null;
  }
 catch (  KeyStoreException ex) {
    throw new CryptoException(res.getString("NoMatchCertificate.exception.message"),ex);
  }
}

public static String matchCertificate ( KeyStore keyStore , X509Certificate cert ) throws CryptoException { try { for ( Enumeration aliases = keyStore . aliases ( ) ; aliases . hasMoreElements ( ) ; ) { String alias = ( String ) aliases . nextElement ( ) ; if ( keyStore . isCertificateEntry ( alias ) ) { X509Certificate compCert = X509CertUtil . convertCertificate ( keyStore . getCertificate ( alias ) ) ; if ( cert . equals ( compCert ) ) { return alias ; } } } return null ; } catch ( KeyStoreException ex ) { throw new CryptoException ( res . getString ( "NoMatchCertificate.exception.message" ) , ex ) ; } }
check whether or not a trusted certificate in the supplied keystore matches the supplied x . 509 certificate .
