boolean validateCertificate ( byte [ ] certPEM ) { if ( certPEM == null ) { return false ; } try { X509Certificate certificate = getX509Certificate ( certPEM ) ; if ( null == certificate ) { throw new Exception ( "Certificate transformation returned null" ) ; } return validateCertificate ( certificate ) ; } catch ( Exception e ) { logger . error ( "Cannot validate certificate. Error is: " + e . getMessage ( ) + "\r\nCertificate (PEM, hex): " + DatatypeConverter . printHexBinary ( certPEM ) ) ; return false ; } }
validateCertificate checks whether the given certificate is trusted . It checks if the certificate is signed by one of the trusted certs in the trust store .