From 00ec592dd14f4e18b5c4c02f903af3a78ccbc830 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Fri, 4 Apr 2014 16:28:14 -0700 Subject: [PATCH] consul: Client initializes TLS settings --- consul/client.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/consul/client.go b/consul/client.go index 74dbc3fba7..5e575ed92d 100644 --- a/consul/client.go +++ b/consul/client.go @@ -1,6 +1,7 @@ package consul import ( + "crypto/tls" "fmt" "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/serf/serf" @@ -78,13 +79,22 @@ func NewClient(config *Config) (*Client, error) { config.LogOutput = os.Stderr } + // Create the tlsConfig + var tlsConfig *tls.Config + var err error + if config.VerifyOutgoing { + if tlsConfig, err = config.OutgoingTLSConfig(); err != nil { + return nil, err + } + } + // Create a logger logger := log.New(config.LogOutput, "", log.LstdFlags) // Create server c := &Client{ config: config, - connPool: NewPool(clientRPCCache), + connPool: NewPool(clientRPCCache, tlsConfig), eventCh: make(chan serf.Event, 256), logger: logger, shutdownCh: make(chan struct{}), @@ -94,7 +104,6 @@ func NewClient(config *Config) (*Client, error) { go c.lanEventHandler() // Initialize the lan Serf - var err error c.serf, err = c.setupSerf(config.SerfLANConfig, c.eventCh, serfLANSnapshot) if err != nil {