Skip to content

Commit

Permalink
etcdmain: check TLS on gateway SRV records
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Romano committed Aug 3, 2016
1 parent 9005e62 commit acaa920
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions etcdmain/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@ import (
"time"

"github.com/coreos/etcd/client"
"github.com/coreos/etcd/pkg/transport"
"github.com/coreos/etcd/proxy/tcpproxy"
"github.com/spf13/cobra"
)

var (
gatewayListenAddr string
gatewayEndpoints []string
gatewayDNSCluster string
getewayRetryDelay time.Duration
gatewayListenAddr string
gatewayEndpoints []string
gatewayDNSCluster string
gatewayInsecureDiscovery bool
getewayRetryDelay time.Duration
gatewayCA string
)

var (
Expand Down Expand Up @@ -64,6 +67,8 @@ func newGatewayStartCommand() *cobra.Command {

cmd.Flags().StringVar(&gatewayListenAddr, "listen-addr", "127.0.0.1:23790", "listen address")
cmd.Flags().StringVar(&gatewayDNSCluster, "discovery-srv", "", "DNS domain used to bootstrap initial cluster")
cmd.Flags().BoolVar(&gatewayInsecureDiscovery, "insecure-discovery", false, "accept insecure SRV records")
cmd.Flags().StringVar(&gatewayCA, "trusted-ca-file", "", "path to the client server TLS CA file.")

cmd.Flags().StringSliceVar(&gatewayEndpoints, "endpoints", []string{"127.0.0.1:2379"}, "comma separated etcd cluster endpoints")

Expand All @@ -81,6 +86,21 @@ func startGateway(cmd *cobra.Command, args []string) {
os.Exit(1)
}
plog.Infof("discovered the cluster %s from %s", eps, gatewayDNSCluster)
// confirm TLS connections are good
if !gatewayInsecureDiscovery {
tlsInfo := transport.TLSInfo{
TrustedCAFile: gatewayCA,
ServerName: gatewayDNSCluster,
}
endpoints, err = transport.ValidateSecureEndpoints(tlsInfo, eps)
if err != nil {
plog.Warningf("%v", err)
}
}
}

if len(endpoints) == 0 {
plog.Fatalf("no endpoints found")
}

l, err := net.Listen("tcp", gatewayListenAddr)
Expand Down

0 comments on commit acaa920

Please sign in to comment.