code: public static void validate(byte[] cert, String pass) throws Exception {
  
          try {
              KeyStore keyStore = KeyStore.getInstance(ALGORITHM);
              keyStore.load(new ByteArrayInputStream(cert), pass.toCharArray());
          } catch (Exception e) {
              throw new Exception("Certificate is not valid!", e);
          }
      }
docs: Check if the file provide is PKCS12
  @param cert certificate to be validated
  @param pass password to be provided
  @throws Exception to indicate an invalid certificate