public static void validateCertificate(X509Certificate cert){
  try {
    cert.checkValidity();
  }
 catch (  Exception e) {
    logAndThrow(String.format("Certificate is not valid: %s",e.getMessage()));
  }
}

public static void validateCertificate ( X509Certificate cert ) { try { cert . checkValidity ( ) ; } catch ( Exception e ) { logAndThrow ( String . format ( "Certificate is not valid: %s" , e . getMessage ( ) ) ) ; } }
checks validity of the given certificate .
