From 7515f11470d72883f5852961c13618dc84b7ae47 Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Sun, 24 Oct 2010 09:53:52 +0100 Subject: [PATCH] Use default root CAs for SSL connections, h/t raylu. --- irc/connection.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/irc/connection.go b/irc/connection.go index 42d7f70..3a88603 100644 --- a/irc/connection.go +++ b/irc/connection.go @@ -5,6 +5,7 @@ import ( "os" "net" "crypto/tls" + "crypto/rand" "fmt" "strings" "time" @@ -98,16 +99,13 @@ func (conn *Conn) Connect(host string, ssl bool, pass ...string) os.Error { } } - var sock net.Conn; - var err os.Error; - if ssl { - sock, err = tls.Dial("tcp", "", host) - } else { - sock, err = net.Dial("tcp", "", host) - } + sock, err := net.Dial("tcp", "", host) if err != nil { return err } + if ssl { + sock = tls.Client(sock, &tls.Config{Rand: rand.Reader, Time: time.Nanoseconds}) + } conn.Host = host conn.SSL = ssl @@ -119,9 +117,8 @@ func (conn *Conn) Connect(host string, ssl bool, pass ...string) os.Error { go conn.send() go conn.recv() - // see getStringMsg() in commands.go for what this does - if p := getStringMsg(pass); p != "" { - conn.Pass(p) + if pass != "" { + conn.Pass(pass) } conn.Nick(conn.Me.Nick) conn.User(conn.Me.Ident, conn.Me.Name)