none
Obtaining SSL/Certificate information in the client on a WCF connection.

    Question

  • This is probably a really easy question to answer but I can't seem to find any information on the subject that helps me.

    From within a client communicating to a WCF service, I would like to obtain details on the Certificate and security level of the connection.  I am using a customBinding across an SSL/https connection.  The customBinding is required for compression so it's not an option to change that.

    Basically, what I am looking for is the equivalent of the web browser padlock functionality.  As in, I want to add an icon and a form to my client application to provide the same functionality as clicking on the padlock in IE/Firefox for web pages.

    • Edited by Devlin Gaza Tuesday, March 27, 2018 6:43 PM
    Tuesday, March 27, 2018 5:31 PM

Answers

  • Hi Devlin,

    For accessing the server certificate, I suggest you try code below:

                ServicePointManager.ServerCertificateValidationCallback +=
                        delegate (object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
                                                System.Security.Cryptography.X509Certificates.X509Chain chain,
                                                System.Net.Security.SslPolicyErrors sslPolicyErrors)
                        {
                            // check the certificate
                            return true; // **** Always accept
                        };
    

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Devlin Gaza Wednesday, March 28, 2018 4:15 PM
    Wednesday, March 28, 2018 7:17 AM
    Moderator

All replies

  • Hi Devlin,

    For accessing the server certificate, I suggest you try code below:

                ServicePointManager.ServerCertificateValidationCallback +=
                        delegate (object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
                                                System.Security.Cryptography.X509Certificates.X509Chain chain,
                                                System.Net.Security.SslPolicyErrors sslPolicyErrors)
                        {
                            // check the certificate
                            return true; // **** Always accept
                        };
    

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Devlin Gaza Wednesday, March 28, 2018 4:15 PM
    Wednesday, March 28, 2018 7:17 AM
    Moderator
  • That did the trick.  I would like to pull additional details, like the actual version of SSL/TLS that was used for the connection but this is more than enough for now, and it also gave me a reference to review the appropriate documentation for additional detail I would like to provide to the user.

    Thanks.

    Wednesday, March 28, 2018 6:48 PM