Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 895
  • Last Modified:

Tcpclient, TcpListener, NetworkStream - Client/Server Security

I will be using Tcpclient, TcpListener, NetworkStream for my Client/Server application which will support 200-1000 users (lots of data and lots of bandwith).

The question is what is the best way to handle security?  I want the data from the client to be encrypted and secure when traveling across the network.  What is the best way to achieve this and can you provide some code that will show an example of a basic tcpclient securing data before shooting it off to a server and the tcplistener on the server (multi-threaded if possible) taking the data then unsecuring it so it can read the data.

Thank you.

  • 3
1 Solution
I have no sample code for you right now, but what you might do, and what I know have been implemented before:
(Assuming you build the connection already)

Sender:EncryptPackage using

don.t press tab and space :D heheh

ok.. continued:

Sender: Encrypt data using it's own 'secret-sender-encrypt' method
Receiver: Encrypt data using it's own 'secret-receiver-encrypt' method and sending it back to sender
Sender: Decrypt using it 'secret-sender-decrypt' method and send to receiver again
Receiver: Decrypt using it 'secret-receiver-decrypt' method and read it.. this should be the original data..

You will see this causes more communication, but I think security will always have it's price.

You might also try out the SSLStream obj:

        Dim client As New System.Net.Sockets.TcpClient()
        Dim myStream As New System.Net.Security.SslStream(client.GetStream())

you might find this discussion interesting as well:

HepenAuthor Commented:
That example is really not that complete. It is just up in the air it seems.

Also do I have to have a certificate that loads from a file to use the SSLstream?

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now