Windows Phone 8 - SSL

Jan 29, 2013 at 1:46 PM
Edited Jan 29, 2013 at 1:47 PM

Hi Kerry!

Is there any progress in this topic? Will websocket4net support SSL for WP8 in near future?

Thanks in advance,

cheers, Alex

Coordinator
Jan 30, 2013 at 4:16 AM

I think the current code in repository can support SSL already, use the source code of WP7 for your WP8 project directly.

Jan 30, 2013 at 2:20 PM
Edited Jan 30, 2013 at 2:26 PM

Hi Kerry,

after porting the WP7 code of BouncyCastle.Crypto, SuperSocket and WebSocket4Net to WP8 I can finally connect to the wss. As soon as i'm connected a handshaked is sent over the wire and i receive the first Messages from my server. When i try to send some Messages: the app hangs. Can you imagine why?

The line (in System.Net.Security.SslStream):

public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
        {
            return m_SecureStream.BeginWrite(buffer, offset, count, callback, state);
        }

Here's my callstack:

> SuperSocket.ClientEngine.Core.DLL!System.Net.Security.SslStream.BeginWrite(byte[] buffer, int offset, int count, System.AsyncCallback callback, object state) Line 151 C#
  SuperSocket.ClientEngine.Core.DLL!SuperSocket.ClientEngine.SslStreamTcpSession.SendInternal(SuperSocket.ClientEngine.PosList<System.ArraySegment<byte>> items) Line 234 C#
  SuperSocket.ClientEngine.Core.DLL!SuperSocket.ClientEngine.TcpClientSession.DequeueSend() Line 296 C#
  SuperSocket.ClientEngine.Core.DLL!SuperSocket.ClientEngine.TcpClientSession.TrySend(System.ArraySegment<byte> segment) Line 266 C#
  SuperSocket.ClientEngine.Core.DLL!SuperSocket.ClientEngine.ClientSession.Send(System.ArraySegment<byte> segment) Line 47 C#
  SuperSocket.ClientEngine.Core.DLL!SuperSocket.ClientEngine.ClientSession.Send(byte[] data, int offset, int length) Line 41 C#
  WebSocket4Net.DLL!WebSocket4Net.Protocol.DraftHybi10Processor.SendDataFragment(WebSocket4Net.WebSocket websocket, int opCode, byte[] playloadData, int offset, int length) Line 169 C#
  WebSocket4Net.DLL!WebSocket4Net.Protocol.DraftHybi10Processor.SendMessage(WebSocket4Net.WebSocket websocket, int opCode, string message) Line 113 C#
  WebSocket4Net.DLL!WebSocket4Net.Protocol.DraftHybi10Processor.SendMessage(WebSocket4Net.WebSocket websocket, string message) Line 192 C#
  WebSocket4Net.DLL!WebSocket4Net.WebSocket.Send(string message) Line 426 C#

Jan 30, 2013 at 3:22 PM

Can you tell when there'll be a stable build (bin-download) for WP8?

Coordinator
Jan 30, 2013 at 5:23 PM

Hello, Do you have a way to write unit test code for WP8 project.

I wrote a Silverlight Test Application and the communication is ok. But I don't know how to verify WP7/WP8 version.

Jan 30, 2013 at 6:06 PM

Can you please create the wp8 assemblies for me? Maybe i made a mistake...

Coordinator
Feb 1, 2013 at 10:28 AM
I have created WP8 project and solution files for WebSocket4Net, you can build it by yourself.

The WP8 assemblies of BouncyCastle and SuperSocket.ClientEngine have been provided in Reference folder.
Feb 1, 2013 at 10:30 AM
Hi Kerry,

thanks a lot man! I'll download and test the whole thing in the next few hours!

cheers, alex
Feb 1, 2013 at 3:00 PM
Edited Feb 1, 2013 at 3:07 PM
Hi Kerry,

OK - just re-downloaded the source-code package and there's no WP8 inside...

i cannot find the WP8 projects nor the reference-assemblies when I download the source from the codeplex-site.
Or do I miss something here?

alex
Coordinator
Feb 1, 2013 at 3:16 PM
Sorry, I have network accessing problem with the git server of codeplex, so the pushing yesterday failed.

You can download the code from github:
https://github.com/kerryjiang/WebSocket4Net
Feb 1, 2013 at 3:18 PM
Thank you for the immediate response - I'll check it out right away.
Feb 1, 2013 at 3:29 PM
Ok, just checked it out and I'm facing the same issue -> connect works, handshake works but i cannot send a message.
Same stacktrace like i provided further up in our discussion.

Maybe i can help you in some way to reproduce the error in your environment?
Coordinator
Feb 1, 2013 at 3:36 PM
Do you know how to write UnitTest code for WP8? I wrote Silverlight Test Application to do unit test, is there a way to do same things for WP8?
Feb 1, 2013 at 3:40 PM
Edited Feb 1, 2013 at 3:41 PM
Never done it before, but maybe this link is useful: http://mobile.dzone.com/articles/windows-phone-8-unity-testing

Seems like you need to create a WP8 app...
Coordinator
Feb 1, 2013 at 4:12 PM
It would be work for me.

I'll try that...
Feb 1, 2013 at 4:14 PM
Many thanks!! I appreciate your commitment!
Feb 11, 2013 at 8:05 AM
Hi Kerry,
do you have any news for me regarding my ssl-wp8-problem?
Thanks in advance - alex
Feb 19, 2013 at 10:30 AM
Edited Feb 19, 2013 at 10:32 AM
How's it going?
Do you think you can fix the issue in the near future? We're unable to release our app at the moment, and we don't want to give the non-ssl version to the store.
Coordinator
Feb 19, 2013 at 12:03 PM
Oh, I had created Test project for WP8, but my Win8 is running in VirtualBox, which leads the WP emulator cannot run.

This problem blocks the producing of this issue.
Feb 19, 2013 at 12:06 PM
Thank you for the info - glad that you're working on it.
How're you supposed to go ahead?
Feb 19, 2013 at 12:38 PM
I'm having the exact same problem as faulandcc. Hangs with the exact same call stack. I've managed to come through a few times when debugging slowly, which leads me to believe this might be a synchronization issue, possibly that simultaneous sends and receives to the same socket object messes things up, i.e. no thread safety. Everything works fine without SSL though...
Coordinator
Feb 19, 2013 at 12:52 PM
Hello wilfuloverride, how do you debug the problem? In a emulator or a real hardware?
Mar 3, 2013 at 11:04 PM
Sorry for late answer, I moved on to another project now. But I did debugging on real hardware!
Coordinator
Apr 22, 2013 at 10:47 AM
I have done a fix on the past days. And the wss function can run in WP8 now.
Apr 25, 2013 at 11:01 AM
kerryjiang wrote:
I have done a fix on the past days. And the wss function can run in WP8 now.
I can confirm that wss working in WP8 app, thanks so much for your effort.
Aug 5, 2013 at 8:40 PM
Hey Kerry,

So I downloaded the source code from this thread and I'm trying to connect to a client's secure production feed, and this is the error I'm getting:

A first chance exception of type 'System.IO.EndOfStreamException' occurred in BouncyCastle.Crypto.DLL
A first chance exception of type 'System.IO.IOException' occurred in BouncyCastle.Crypto.DLL
A first chance exception of type 'System.IO.IOException' occurred in SuperSocket.ClientEngine.Core.DLL
MainPage - WebSocketError: Internal TLS error, this could be an attack
MainPage - Source: SuperSocket.ClientEngine.Core
MainPage - StackTrace: at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
at SuperSocket.ClientEngine.SslStreamTcpSession.OnAuthenticated(IAsyncResult result)

Think you can advise me more on the details of this bug? The production feed is using a standard certificate authority, geotrust. I'm still learning about certificates, so I'm curious if it's related, and if I need to do additional steps other than simply "connecting". Any help would be greatly appreciated.
Coordinator
Aug 6, 2013 at 3:05 AM
It seems a certificate issue, could you tell me your url which was used for connecting and the certificate's Common Name?
Coordinator
Aug 19, 2013 at 9:34 AM
I also produced the same issue with vhuynh, but the cause of my problem is the server doesn't support TLS/SSL.
Dec 28, 2013 at 6:25 PM
Hello, i am having the same issue.
How can i modify my certificate details?
Thanks
Coordinator
Dec 29, 2013 at 2:38 AM
Generate a new certificate with the correct dns and then use it in your server program