locked
Need help getting StreamSocket.upgradeToSslAsync working

    Question

  • I'm trying to write some test code to confirm a few pieces of upgradeToSslAsync's behavior.  The finalized code wouldn't look like this but here is my test code:

    var sock = new Windows.Networking.Sockets.StreamSocket();
    sock.connectAsync(new Windows.Networking.HostName("10.116.32.101"), "443", Windows.Networking.Sockets.SocketProtectionLevel.plainSocket).then(
       function success() {
          sock.upgradeToSslAsync(Windows.Networking.Sockets.SocketProtectionLevel.ssl, new Windows.Networking.Sockets.HostName("broker.testdomain.int")).then(
             function success() {
                // Blah
             },
             function error(reason) {
                // Blah
             });
       },
       function error(reason) {
          // Blah
       });

    When I run that code, the upgradeToSslAsync call immediately throws an exception saying "Object doesn't support this action".  Is that a notification from the socket that the server side does not support upgrade to SSL or is there a different issue in my code that I'm not noticing?

    Tuesday, August 7, 2012 7:21 PM

Answers

  • Hi Adam,

    The debugger is your friend!  If you break on that function and inspect your variables, you will see "Windows.Networking.Sockets" does not have a member "HostName".  You want to change your code per the documentation to this:

      sock.upgradeToSslAsync(Windows.Networking.Sockets.SocketProtectionLevel.ssl,

    newWindows.Networking.HostName("jsanders4")).then(

                


    Jeff Sanders (MSFT)

    Wednesday, August 8, 2012 3:54 PM
    Moderator

All replies

  • Hi Adam,

    The debugger is your friend!  If you break on that function and inspect your variables, you will see "Windows.Networking.Sockets" does not have a member "HostName".  You want to change your code per the documentation to this:

      sock.upgradeToSslAsync(Windows.Networking.Sockets.SocketProtectionLevel.ssl,

    newWindows.Networking.HostName("jsanders4")).then(

                


    Jeff Sanders (MSFT)

    Wednesday, August 8, 2012 3:54 PM
    Moderator
  • Ah, yeah you're right, thanks!
    Wednesday, August 8, 2012 4:02 PM