public static String fingerprint(X509Certificate cert) throws CertificateException {
  try {
    MessageDigest md=MessageDigest.getInstance("SHA-512");
    md.update(cert.getEncoded());
    return BytePrinter.compactHex(md.digest());
  }
 catch (  NoSuchAlgorithmException e) {
    throw new CertificateException("Cannot use TLS on this platform, because SHA-512 message digest algorithm is not available: " + e.getMessage(),e);
  }
}

public static String fingerprint ( X509Certificate cert ) throws CertificateException { try { MessageDigest md = MessageDigest . getInstance ( "SHA-512" ) ; md . update ( cert . getEncoded ( ) ) ; return BytePrinter . compactHex ( md . digest ( ) ) ; } catch ( NoSuchAlgorithmException e ) { throw new CertificateException ( "Cannot use TLS on this platform, because SHA-512 message digest algorithm is not available: " + e . getMessage ( ) , e ) ; } }
calculate the certificate fingerprint - simply the sha - 512 hash of the der - encoded certificate .
