EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Windows Phone sample?

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#19857
Posted: 04/19/2012 10:28:45
by Eugene Mayevski (EldoS Corp.)

The most possible reason is that certificate validation failed. Check that your OnCertificateValidate event handler sets Validate to true.


Sincerely yours
Eugene Mayevski
#19859
Posted: 04/19/2012 11:39:28
by L haitao (Basic support level)
Joined: 04/17/2012
Posts: 16

TElSimpleSSLClient works on WindowsPhone
which folder's dll do you use?
NET_40?SILVERLIGHT_40? WP7? WP7.5?

I use the folder of WP7.5 but the same error.

you have said that TElSimpleSSLClient works on WindowsPhone without any problems.
can I have a look you sample ?

My E-mail is tj2005lihaitao@sina.com
Thanks very much
#19860
Posted: 04/19/2012 11:45:40
by Vsevolod Ievgiienko (EldoS Corp.)

I use assemblies from WP7.5 folder and project targets Windows Phone OS 7.1. The sample is very simple:

Code
using SBUtils;
using SBSimpleSSL;
using SBSSLCommon;
using SBX509;
...
public MainPage()
        {
...
            SBUtils.Unit.SetLicenseKey("...");

            TElSimpleSSLClient c = new TElSimpleSSLClient();
            c.OnCertificateValidate += new TSBCertificateValidateEvent(c_OnCertificateValidate);

            c.Address = "eldos.com";
            c.Port = 443;
            c.Open();
            c.Close(false);
        }

        private void c_OnCertificateValidate(object Sender, TElX509Certificate X509Certificate, ref TSBBoolean Validate)
        {
            Validate = true;
        }
#19861
Posted: 04/19/2012 11:59:42
by L haitao (Basic support level)
Joined: 04/17/2012
Posts: 16

so easy sample.

It can works on WindowsPhone without any problems ?

Now it is Late at night. our test server is closed in my company.

tomorrow I will try it.
thanks
#19862
Posted: 04/19/2012 12:05:15
by Vsevolod Ievgiienko (EldoS Corp.)

Quote
It can works on WindowsPhone without any problems ?

Yes it works. You can check this with any SSL-enabled server.
#19868
Posted: 04/19/2012 21:15:36
by L haitao (Basic support level)
Joined: 04/17/2012
Posts: 16

I'm very happy,I find the answer of that problem.
#19900
Posted: 04/23/2012 00:10:19
by L haitao (Basic support level)
Joined: 04/17/2012
Posts: 16

Code
public static void HandleData(byte[] sBuf, ref byte[] rBuf)
        {
      
            if (SecureClient.Active)
            {
                SecureClient.SendData(sBuf, 0, sBuf.Length);
            }

            int ToRead;
            while (SecureClient.Active)
            {
                try
                {
                    ToRead = 512;
                    rBuf = new byte[ToRead];
                    //There is a err at here
                    SecureClient.ReceiveData(ref rBuf, ref ToRead, true);
                 }
                catch (Exception )
                {
                    break;
                }
            }
        }

wp7 sslsocket I can send some data to server.
but when ReceiveData there is a err Connection lost (error code is 10057)
#19901
Posted: 04/23/2012 00:48:28
by Eugene Mayevski (EldoS Corp.)

This is correct behavior - the component has no way to switch the state (Active property) unless some operation on the socket is performed. And if the operation is performed on inactive socket, exception will be thrown.

Right approach is to handle exceptions when calling component's methods and treat them as disconnection. Note that after disconnection you still have to call Close(true) to close the socket and cleanup resources.

So I'd rewrite your code into the following:

Code
public static void HandleData(byte[] sBuf, ref byte[] rBuf)
{

if (SecureClient.Active)
{
    SecureClient.SendData(sBuf, 0, sBuf.Length);

    rBuf = new byte[65536];

    while (true)
    {
        try
        {
            ToRead = 65536; // there's little sense to use buffers smaller than 64Kb
            SecureClient.ReceiveData(ref rBuf, ref ToRead, true);
            // consume data here
        }
        catch (Exception )
        {
            break;
        }
    }
}


Note that call to ReceiveData in your code makes no sense as it is written now: if you read data in the loop, you need to *append* them, and in your code each call to ReceiveData will override previously requested data. This is ok, if you consume the data by copying it to some other place, but you are receiving *into* the final destination. So your code must be adjusted.


Sincerely yours
Eugene Mayevski
#19910
Posted: 04/24/2012 01:15:15
by L haitao (Basic support level)
Joined: 04/17/2012
Posts: 16

I find that using SecureClient send and receive data
spend much time than System's socket.

Using System's socket handle data is very fast!
#19911
Posted: 04/24/2012 02:47:06
by Eugene Mayevski (EldoS Corp.)

Evaluation license has intentional speed limits. You can request non-restricted 30-day license using the key request form.


Sincerely yours
Eugene Mayevski
Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.

Reply

Statistics

Topic viewed 30048 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!