optional TLS config

This commit is contained in:
Marin 2014-09-14 23:15:56 -07:00
parent 9276abaad9
commit 41fd432f88

View File

@ -135,7 +135,7 @@ type Options struct {
}
// NewClient establishes a new Client connection based on a set of Options.
func (o Options) NewClient() (*Client, error) {
func (o Options) NewClient(tlsCfg ...tls.Config) (*Client, error) {
host := o.Host
c, err := connect(host, o.User, o.Password)
if err != nil {
@ -146,7 +146,12 @@ func (o Options) NewClient() (*Client, error) {
if o.NoTLS {
client.conn = c
} else {
tlsconn := tls.Client(c, &DefaultConfig)
var tlsconn *tls.Conn
if len(tlsCfg) > 0 {
tlsconn = tls.Client(c, &tlsCfg[0])
} else {
tlsconn = tls.Client(c, &DefaultConfig)
}
if err = tlsconn.Handshake(); err != nil {
return nil, err
}