title: How to retrieve/compute an X509 certificate's thumbprint in Java?
body: <p>I have a java client that is calling a web service operation which takes a certificate "thumbprint" as a parameter. I believe the thumbprint is some kind of SHA1 hash, in hexadecimal string format, of the cert's public key, but I'm not sure.</p>
  
  <p>The .NET framework seems to include a simple way to get this value (<a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate2.thumbprint.aspx" rel="noreferrer">X509Certificate2.Thumbprint</a> property). Viewing a .cer file's properties in Windows also displays the thumbprint, which looks like:</p>
  
  <pre><code>a6 9c fd b0 58 0d a4 ee ae 9a 47 75 24 c3 0b 9f 5d b6 1c 77
  </code></pre>
  
  <p>My question is therefore: Does anybody know how to retrieve or compute this thumbprint string within Java, if I have an instance of a <a href="http://docs.oracle.com/javase/7/docs/api/javax/security/cert/X509Certificate.html" rel="noreferrer">java.security.cert.X509Certificate</a>?</p>