Showing posts with label Certificate. Show all posts
Showing posts with label Certificate. Show all posts

Friday, October 15, 2010

Client Certificate: FormatException Invalid Hexadecimal string format


Ran into this exception while trying to add a client certificate to a SOAP client.
After installing the certificate through the mmc->Certificate snap-in I tried to copy the Thumbprint of the said certificate so that my client application would be able to use it.
The snap-in dispays the thumbprint as follows:
34 f7 83 fc 40 f6 1d d7 1c 92 43 c9 a5 af aa 42 ba 5e 27 db
So I just copied it and inserted it into my app.config.
First exception was from the fact that the thumbprint needs to be a string without spaces, converted the string to:
34f783fc40f61dd71c9243c9a5afaa42ba5e27db
This time I got the exception FormatException: Invalid Hexadecimal string format. I copied the string from the snap-in again and this time I pasted it into Notepad++ to see if there were anything else hidden in the string. As it turned out there was.
?34 f7 83 fc 40 f6 1d d7 1c 92 43 c9 a5 af aa 42 ba 5e 27 db
So pasting back into the app.config and this time removing the starting character and the starting quote and manually writing them back and the just to be safe doing the same thing with the ending character and the ending quote it worked. Don’t forget to remove the spaces as well.
Hope this helps somebody out there as it really slowed me down last night. : )