How to find certificate by its thumbprint in C#

Just stumbled over this question when Googling for the same issue, and found the answer here: if, like me, you obtained your “source” thumbprint from MMC by highlighting the thumbprint and copying it to the clipboard, you’ve almost certainly caught an invisible character at the start of the screen, so:

string certThumbPrint = “‎‎fe14593dd66b2406c5269d742d04b6e1ab03adb1”;

is actually

string certThumbPrint = “‎‎INVISIBLECHARACTERfe14593dd66b2406c5269d742d04b6e1ab03adb1″;

If you delete this invisible character (you can tell it’s there when you press backspace or delete beside it and nothing seems to happen), or just retype the thumbprint by hand, your code should work fine. Now if only Visual Studio had a “show invisible characters” option …

Leave a Comment