title: compare 2 x509 certificate in java
body: <p>I have been provided a byte array and an X509 certificate.  I can generate X509 certificate from the byte array using below code.</p>
  
  <pre><code>CertificateFactory certificatefactory = CertificateFactory.getInstance("X.509");
  InputStream in = new ByteArrayInputStream(bytes);
  X509Certificate cert = (X509Certificate)certificatefactory.generateCertificate(in);
  </code></pre>
  
  <p>Please guide me how to verify that the generated X509 with the one which was provided to me.</p>