mirror of https://github.com/fluffle/goirc
Use default root CAs for SSL connections, h/t raylu.
This commit is contained in:
parent
05e3500a3c
commit
7515f11470
|
@ -5,6 +5,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"net"
|
"net"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -98,16 +99,13 @@ func (conn *Conn) Connect(host string, ssl bool, pass ...string) os.Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var sock net.Conn;
|
sock, err := net.Dial("tcp", "", host)
|
||||||
var err os.Error;
|
|
||||||
if ssl {
|
|
||||||
sock, err = tls.Dial("tcp", "", host)
|
|
||||||
} else {
|
|
||||||
sock, err = net.Dial("tcp", "", host)
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if ssl {
|
||||||
|
sock = tls.Client(sock, &tls.Config{Rand: rand.Reader, Time: time.Nanoseconds})
|
||||||
|
}
|
||||||
|
|
||||||
conn.Host = host
|
conn.Host = host
|
||||||
conn.SSL = ssl
|
conn.SSL = ssl
|
||||||
|
@ -119,9 +117,8 @@ func (conn *Conn) Connect(host string, ssl bool, pass ...string) os.Error {
|
||||||
go conn.send()
|
go conn.send()
|
||||||
go conn.recv()
|
go conn.recv()
|
||||||
|
|
||||||
// see getStringMsg() in commands.go for what this does
|
if pass != "" {
|
||||||
if p := getStringMsg(pass); p != "" {
|
conn.Pass(pass)
|
||||||
conn.Pass(p)
|
|
||||||
}
|
}
|
||||||
conn.Nick(conn.Me.Nick)
|
conn.Nick(conn.Me.Nick)
|
||||||
conn.User(conn.Me.Ident, conn.Me.Name)
|
conn.User(conn.Me.Ident, conn.Me.Name)
|
||||||
|
|
Loading…
Reference in New Issue