The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
StreamSocket.Information.ServerCertificate is not available in windows phone 8.1 silverlight? RRS feed

  • Question

  • Hi,

    I am developing an library. Currently implementing SSL Pinning feature: After spending lot of time on internet found the API namespace:

    Windows.Networking.Sockets

    But, The property "StreamSocket.Information.ServerCertificate" is available in windows phone 8.1 runtime and Not able to access the same in Windows Phone 8.1 Silverlight.

    Please help me to use this API in Silverlight environment.

    Thanks, 


    Pallam Madhukar Windows Phone Developer

    Thursday, February 18, 2016 12:57 PM

Answers

  • Hi Barry,

    I am able to access ServerCertificate in Windows Runtime Component. So I have created WRC and added reference in Silverlight project and getting the ServerCertificate to do SSL Pinning. Hope This may helps some one in feature.

    Thanks,


    Pallam Madhukar Windows Phone Developer

    Monday, February 22, 2016 7:08 PM

All replies

  • @Pallam,

    Based on document it is true that this API is only available on WinRT:http://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.sockets.streamsocketinformation.servercertificate.aspx

    I'm trying to consult this issue and I will update it here if I get any response. In my point of view, maybe we need to use some other libraries.

    Best regards,

    Barry


    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, February 19, 2016 10:01 AM
  • Thanks Barry,

    It will help us very much, if you provide an alternative way or library.

    Thanks,


    Pallam Madhukar Windows Phone Developer

    Friday, February 19, 2016 10:12 AM
  • Hi Barry,

    I am able to access ServerCertificate in Windows Runtime Component. So I have created WRC and added reference in Silverlight project and getting the ServerCertificate to do SSL Pinning. Hope This may helps some one in feature.

    Thanks,


    Pallam Madhukar Windows Phone Developer

    Monday, February 22, 2016 7:08 PM
  • Hi Barry,

    I am able to access ServerCertificate in Windows Runtime Component. So I have created WRC and added reference in Silverlight project and getting the ServerCertificate to do SSL Pinning. Hope This may helps some one in feature.

    Thanks,


    Pallam Madhukar Windows Phone Developer

    Hi Pallam

    We have a project that needs SSL pinning. We're new to WP development, so we're struggling to find a solution.

    It would help us greatly if you could provide some code or a sample project with your solution.

    Thank you

    Tuesday, March 1, 2016 12:52 PM
  • Hi Simon,

    SSL Pinning is not possible for WP8 using windows API. But I have implemented  SSL Pinning in windows Phone 8.1 silverlight.

    If your working with WP8.1 silverlight you can use my following solution:

    using (StreamSocket socket = new StreamSocket())
                        {
                            await socket.ConnectAsync(new HostName(hostName), string.Empty + remoteServiceName, protectionLevel);
                            return socket.Information.ServerIntermediateCertificates;   
                        }

    The above code will return server certificates. Then,

    //Here trusedCertificates: bundled certificates with your app

    //serverIntermediateCertificates : certificates received from server

    foreach (var trusted in trusedCertificates) { byte[] expected = trusted.GetHashValue(); for (int i = 0; i < serverIntermediateCertificates.Count; i++) { byte[] thumbprint = serverIntermediateCertificates[i].GetHashValue(); if (thumbprint.SequenceEqual(expected)) {

    //secured connection return true; } } }

     

    If your WP8.1 project is WinRT you can have two code snippets in single project. If your project is WP8.1 Silverlight you have to wright the first code snippent in Windows Runtime Component project and add reference in your project.

    Thanks,


    Pallam Madhukar Windows Phone Developer


    Wednesday, March 2, 2016 9:28 PM