I have been provided a byte array and an X509 certificate. I can generate X509 certificate from the byte array using below code.
CertificateFactory certificatefactory = CertificateFactory.getInstance("X.509");
InputStream in = new ByteArrayInputStream(bytes);
X509Certificate cert = (X509Certificate)certificatefactory.generateCertificate(in);
Please guide me how to verify that the generated X509 with the one which was provided to me.
Simply use certificate.equals(otherCertificate)
: the equals()
method will compare them correctly, with a specific implementation for each certificate subclass.
See the javadoc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With