c# - 通过 SSL 连接到 IRC

标签 c# ssl irc

谁能给我一个如何与 IRC 服务器建立 SSL 连接的例子吗?

我曾尝试阅读有关 SslStream 的内容,但我就是不明白。我可以使用以下方法在没有 SSL 的情况下连接到 IRC:

        sock.Connect(server, port);
        if (!sock.Connected) {
            Console.WriteLine("Failed to connect!");
            return;
        }
        input = new System.IO.StreamReader(sock.GetStream());
        output = new System.IO.StreamWriter(sock.GetStream());

        output.Write("USER " + nick + " 0 * :" + owner + "\r\n" + "NICK " + nick + "\r\n");
        output.Flush();

        //Process each line received from irc server
        for (buf = input.ReadLine(); ; buf = input.ReadLine()) {
            //Display received irc message
            //Console.WriteLine(buf);
            if (buf.Split(' ')[1] == "332") {
                Console.WriteLine(buf.Split(new char[] { ' ' }, 5)[4]);
            }
            //Send pong reply to any ping messages
            if (buf.StartsWith("PING ")) {
                output.Write(buf.Replace("PING", "PONG") + "\r\n"); output.Flush();
            }
            if (buf[0] != ':') continue;
            if (buf.Split(' ')[1] == "001") {
                output.Write(
                    "MODE " + nick + " \r\n" +
                    "JOIN " + chan + "\r\n"
                );
                output.Flush();
            }
        }
    }
}

最佳答案

试试这个:

conn, err = tls.Dial("tcp", HOST+":"+PORT, &tls.Config{InsecureSkipVerify: true})

关于c# - 通过 SSL 连接到 IRC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26531374/

相关文章:

c# - 等于未实现

c# - 在传递给 C 或 C# 中的函数时,数组是否像指针一样工作?

c# - 在 Silverlight 中循环画笔以获得所有可能的颜色

node.js - 从 nodejs 调用 https - 将数字 cer 文件放在哪里?

c# - 在控制台应用程序中等待异步操作后,WCF 客户端挂起任何操作

security - IIS 6 中的自签名 SSL 证书

javascript - 在 JavaScript 上请求客户端证书

ruby-on-rails - 识别服务-IRC

python - 使用多处理和套接字时出现 SSL 错误

networking - 没有端口转发可以做P2P吗?