-1

Could someone please show me an example of how to make an SSL connection to an IRC server?

I have tried reading about SslStreams but I just don't get it. I am able to connect to IRC without SSL using this:

        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();
            }
        }
    }
}
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52

1 Answers1

-1

Try this:

conn, err = tls.Dial("tcp", HOST+":"+PORT, &tls.Config{InsecureSkipVerify: true})
ProgramFOX
  • 6,131
  • 11
  • 45
  • 51