add some logging

This commit is contained in:
Brian Matheson 2019-04-17 19:37:43 +00:00
parent 86f36fc0ca
commit 9b71884b9c
1 changed files with 6 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"crypto/tls"
"crypto/x509"
"errors"
"log"
"time"
etcd "github.com/coreos/etcd/clientv3"
@ -17,8 +18,11 @@ type EasyConfig struct {
}
func (c EasyConfig) prepare() (etcd.Config, error) {
log.Println("enter prepare() for EasyConfig")
log.Printf("clientCert is '%s'", c.ClientCert)
cert, err := tls.X509KeyPair([]byte(c.ClientCert), []byte(c.ClientKey))
if err != nil {
log.Println("error building keypair")
return etcd.Config{}, err
}
@ -40,12 +44,14 @@ func (c EasyConfig) prepare() (etcd.Config, error) {
conn, err := tls.Dial("tcp", c.Endpoints[0], tc)
if err != nil {
log.Printf("can't connect to %s:%s", c.Endpoints[0], err)
return etcd.Config{}, err
}
defer conn.Close()
err = conn.Handshake()
if err != nil {
log.Printf("failed tls handshake with %s:%s", c.Endpoints[0], err)
return etcd.Config{}, err
}