I donβt think that comparing two signatures is enough, unless your code directly receives certificates from any instance, which ensures that the signature has also been verified on the certificate itself. Therefore, in many cases, I would say no.
I believe that the most flexible, correct way would be to verify the integrity of the two certificates (body versus signature) individually, and then directly compare all the information in the certificates that you need to be identical. (I do it this way because I'm not sure if you need full identification).
However, if your goal is to verify the certificate sent by the server for authentication, then it is not necessary to have a copy of the entire certificate in your code; in this case, you can check the server certificate, and then check its body for a secure hash, which is stored in your application.
source share