在 C# 中,在服务器端使用 SslStream.AuthenticateAsServer() 有什么意义?

问题描述

我正在尝试侦听端口上的安全 TCP 连接。我正在浏览 microsoft docs 上的服务器代码示例。我粘贴在这里以供快速参考:

static void ProcessClient (TcpClient client)
    {
        // A client has connected. Create the
        // SslStream using the client's network stream.
        SslStream sslStream = new SslStream(
            client.GetStream(),false);
        // Authenticate the server but don't require the client to authenticate.
        try
        {
            sslStream.AuthenticateAsServer(serverCertificate,clientCertificateRequired: false,checkCertificateRevocation: true);

            // Display the properties and settings for the authenticated stream.
            DisplaySecurityLevel(sslStream);
            DisplaySecurityServices(sslStream);
            DisplayCertificateInformation(sslStream);
            DisplayStreamProperties(sslStream);

我的疑问是为什么服务器要对自己进行身份验证?或者我在这里遗漏了什么。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)