public static boolean isCertificateException(Throwable t){
  while (t != null) {
    if (t instanceof SSLHandshakeException || t instanceof GeneralSecurityException) {
      return true;
    }
    t=t.getCause();
  }
  return false;
}

public static boolean isCertificateException ( Throwable t ) { while ( t != null ) { if ( t instanceof SSLHandshakeException || t instanceof GeneralSecurityException ) { return true ; } t = t . getCause ( ) ; } return false ; }
tells whether the provided throwable was caused because of a problem with a certificate while trying to establish a connection .
