none
[WPSL]How to compare(check equal or not) Windows.Security.Cryptography.Certificates.Certificate objects RRS feed

  • Question

  • Hi,

    I am creating SSL Pinning: Validating server certificates with bundled certificates.

    I am able to retrieve Server Certificates and bundled certificates. I am struct at comparing two certificates.

    I have used below code but not getting excepted result.

    foreach (var trusted in trusedCertificates)
                {
                    byte[] expected = trusted.GetHashValue();
                    for (int i = 0; i < serverCerts.Count; i++)
                    {
                        byte[] thumbprint = serverCerts[i].GetHashValue();
                        if (thumbprint.SequenceEqual(expected))
                        {
                            return true;
                        }
                        thumbprint = null;
                    }
                    expected = null;
                }
                return false;


    Please suggest me.

    Thanks, 


    Pallam Madhukar Windows Phone Developer


    Thursday, March 31, 2016 4:00 PM

All replies

  • Hi Pallam Madhukar,

    As a friendly reminder please make sure to add the appropriate tags to the title of your post as per Guide to posting: subject line tags

    Could you tell us what type is your APP?

    >>” I have used below code but not getting excepted result.

    Do you always get false?

    Have you test the code to compare  same Certificate

    Best Regards,

    guang9Bear


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 1, 2016 9:09 AM
  • Hi guang9Bear,

    I am developing for Windows Phone 8.1 Silverlight. I have browsed https://www.google.com and saved certificate. Then I have bundled certificate and using StreamSocket API, I got serverCertificate and ServerIntermediateCertificates. and used above method to compare. But none of the ServerIntermediateCertificates are matched with bundled certificate.

    But same thing is working for https://www.facebook.com/ : The ServerCertificate matched with Bundled facebook certificate. 

    Do you have any Idea?

    Thanks,


    Pallam Madhukar Windows Phone Developer



    Friday, April 1, 2016 9:33 AM