Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get Thumbprint of a cert??

843811Mar 7 2005 — edited Dec 5 2009
Hi,
I use 1.4.2 jdk. I need to have secure communications with Directory servers - meaning work with SSLs. I want to get the value of thumbprint of an X509Certificate retrieved from a directory server. How can I do that? I realized there is no direct method call on X509Certificate class.

Searching online blessed me with a link related to this:
http://archives.java.sun.com/cgi-bin/wa?A2=ind0407&L=java-security&F=&S=&P=4456
I used the following method to convert bytes into Hexadecimal strings:
******************
static String toHexString(byte[] buf, int off, int len)
{
StringBuffer str = new StringBuffer();
for (int i = 0; i < len; i++)
{
String HEX = "0123456789abcdef";
str.append(HEX.charAt(buf[i+off] >>> 4 & 0x0F));
str.append(HEX.charAt(buf[i+off] & 0x0F));
}
return str.toString();
}
*********************************

The resultant string is a valid String, but it does not look like a Thumbprint. it looks some thing like "acedbc024h759jkdhuu2885973jh8dgjj5", as oppsed to a typical Thumprint looking like "2f f7 67 uy 92 g4 r4 57 5h j7 h2 8f".

I would appreciate the help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 2 2010
Added on Mar 7 2005
3 comments
408 views