Browse Source

etcdmain: support v3 tls

Anthony Romano 10 years ago
parent
commit
563850bcc1
1 changed files with 11 additions and 1 deletions
  1. 11 1
      etcdmain/etcd.go

+ 11 - 1
etcdmain/etcd.go

@@ -33,6 +33,7 @@ import (
 	"github.com/coreos/etcd/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
 	"github.com/coreos/etcd/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus"
 	"github.com/coreos/etcd/Godeps/_workspace/src/google.golang.org/grpc"
+	"github.com/coreos/etcd/Godeps/_workspace/src/google.golang.org/grpc/credentials"
 	"github.com/coreos/etcd/discovery"
 	"github.com/coreos/etcd/etcdserver"
 	"github.com/coreos/etcd/etcdserver/api/v3rpc"
@@ -330,7 +331,16 @@ func startEtcd(cfg *config) (<-chan struct{}, error) {
 
 	if cfg.v3demo {
 		// set up v3 demo rpc
-		grpcServer := grpc.NewServer()
+		creds, err := credentials.NewServerTLSFromFile(
+			cfg.clientTLSInfo.CertFile,
+			cfg.clientTLSInfo.KeyFile)
+		if err != nil {
+			s.Stop()
+			<-s.StopNotify()
+			return nil, err
+		}
+
+		grpcServer := grpc.NewServer(grpc.Creds(creds))
 		etcdserverpb.RegisterKVServer(grpcServer, v3rpc.NewKVServer(s))
 		etcdserverpb.RegisterWatchServer(grpcServer, v3rpc.NewWatchServer(s))
 		etcdserverpb.RegisterLeaseServer(grpcServer, v3rpc.NewLeaseServer(s))