简体   繁体   English

保护 C# TcpClient 操作

[英]Securing C# TcpClient Operation

I have a couple of questions about C#.NET client/server applications that communicate via Tcp.我有几个关于通过 Tcp 通信的 C#.NET 客户端/服务器应用程序的问题。

  1. How can I best secure my Tcp listener from buffer overflow attacks?如何最好地保护我的 Tcp 侦听器免受缓冲区溢出攻击? I would imagine it occurs at the point at which I read a line off the StreamReader that is associated with the given TcpClient's NetworkStream, but I don't know specifics.我想它发生在我从与给定 TcpClient 的 NetworkStream 相关联的 StreamReader 中读取一行的时候,但我不知道具体细节。

  2. Would someone point me to a really good TcpClient .NET with SSL (via SslStream I guess) tutorial or document?有人会向我指出一个非常好的 TcpClient .NET with SSL(我猜是通过 SslStream)教程或文档吗?

Thanks guys.谢谢你们。

  1. .NET throws exceptions if you try to write outside buffers.如果您尝试写入外部缓冲区,.NET 将引发异常。

  2. That's a very broad question.这是一个非常广泛的问题。 You'll just wrap the NetworkStream with a SslStream and authenticate as a client or server.您只需使用 SslStream 包装 NetworkStream 并作为客户端或服务器进行身份验证。

Example:例子:

var secureStream = new SslStream(tcpClient.GetStream());

MSDN has an example here . MSDN 有一个例子here

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM