4

I have two certificate thumbprints, retrieved from Microsoft Management Console.

When I copy/paste the values into my program, and then manually type the same values to perform an equality check, they fail.

Does anyone know why, when pasting the string value in, it doesn't pass the equality check, but when manually typing it in it does? As far as I can see, they are identical values, so shouldn't both be true?

public void DoSomething()
{
    const string thumbprint1  = "‎1F279488F131074FC7B34B9AF6E6B087678404F2";
    const string thumbprint2  = "1F279488F131074FC7B34B9AF6E6B087678404F2";

    Debug.WriteLine("thumbprint1 = {0}\n", ("1F279488F131074FC7B34B9AF6E6B087678404F2" == thumbprint1));
    Debug.WriteLine("thumbprint2 = {0}\n", ("1F279488F131074FC7B34B9AF6E6B087678404F2" == thumbprint2));
}

Here's an image of the comparison results in Visual Studio:

enter image description here

Grant Winney
  • 65,241
  • 13
  • 115
  • 165
  • Please paste your code and output here directly, not as an image. Use code block highlighting for both (the `{}` button in the editor). – Mat Sep 20 '14 at 13:38

1 Answers1

9

If you have copied and pasted thumbprints from MMC, you may find that one of the thumbprints has a special hidden character at the beginning of the thumbprint.

Press delete in front of the thumbprint to delete the hidden character, which will fix the problem.

Grant Winney
  • 65,241
  • 13
  • 115
  • 165