EldoS | Feel safer!

Software components for data protection, secure storage and transfer

using ElClientSSLSocket to replace regular socket

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#14158
Posted: 08/10/2010 10:09:38
by Shaun OM (Standard support level)
Joined: 08/10/2010
Posts: 12

Hi,
I have a working application using System.Net.Sockets.Socket.
I want the simplest possible way of swapping in an SSL version (assuming this would be ElClientSSLSocket).

I was hoping to just swap the definitions over, hook up the OnCertificateValidate and be on my way but for starters the constructor will not allow an equivalent of
new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP)

Could you please advise on the simplest possible way of swapping in your component.

Kind regards,
Shaun
#14159
Posted: 08/10/2010 12:16:36
by Eugene Mayevski (EldoS Corp.)

Yes, ElClientSSLSocket was designed to be used exactly in the way you described. However, since SSL is always stream-based (there exists DTLS protocol for UDP sockets, it's supported but using different component), the constructor in ElClientSSLSocket is different.


Sincerely yours
Eugene Mayevski
#14160
Posted: 08/10/2010 13:21:22
by Shaun OM (Standard support level)
Joined: 08/10/2010
Posts: 12

This sounds promising. Do you have some sample code to show me how to implement ElClientSSLSocket in the way discussed?

Note: The sample code shows TElSecureClient based on top of a regular socket but there's a lot of extra code involved in that implementation.

Thanks
Shaun
#14161
Posted: 08/10/2010 14:24:35
by Eugene Mayevski (EldoS Corp.)

There's a sample code for ElClientSSLSocket available as well, please search through Samples folder for "ElClientSSLSocket".


Sincerely yours
Eugene Mayevski
#14162
Posted: 08/10/2010 14:40:17
by Shaun OM (Standard support level)
Joined: 08/10/2010
Posts: 12

Thanks, haven't been able track down the samples folder that you refer to.
Either way, it's looking like my implementation is nearly working.

BUT
it gives an error when I try and do this
netStream = new NetworkStream(myClient.Socket);
where myClient is an ElClientSSLSocket. What do you recommend that I do to remedy this ?

Thanks for the speedy help!
Shaun
#14163
Posted: 08/10/2010 14:49:15
by Eugene Mayevski (EldoS Corp.)

Due to bad .NET Framework design (it was not designed to allow creation of descendant classes) ElSimpleSSLSocket just copies the interface of Socket class, but it's not a descendant of socket class. So unfortunately you can't pass it as a replacement for Socket class to other methods and classes. It's Microsoft to blame, not us :).


Sincerely yours
Eugene Mayevski
#14164
Posted: 08/10/2010 15:03:09
by Shaun OM (Standard support level)
Joined: 08/10/2010
Posts: 12

I have it working :)
for anyone else reading this post, then I did this by abandoning the netStream and using the methods of the ElClientSSLSocket.

eg
IAsyncResult ias = netStream.BeginWrite(dataToSend, 0, dataToSend.Length, ar, netStream);

replaced with

IAsyncResult ias = myClient.BeginSend(dataToSend, 0, dataToSend.Length, ar, netStream);

Eugene, If you find the sample then that would be handy as it's taken me quite a while to get this far and there's always a chance I may have overlooked an important detail.

Many thanks
Shaun
Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.

Reply

Statistics

Topic viewed 1223 times

Number of guests: 2, 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!