From 0f7b2dbaf0775beda8080a09118f20c995642eed Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Fri, 28 Apr 2017 22:30:32 -0700 Subject: [PATCH] server: do ssl good --- server/server.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/server.go b/server/server.go index 05f8f5b..ab066a9 100644 --- a/server/server.go +++ b/server/server.go @@ -14,6 +14,7 @@ import ( "github.com/mtneug/pkg/ulid" "golang.org/x/crypto/acme/autocert" "google.golang.org/grpc" + "google.golang.org/grpc/credentials" ) // RPC constants @@ -89,14 +90,14 @@ func New(cfg Config) (*Server, error) { s.ts = ts go ts.ListenAndServe() - gs := grpc.NewServer() + gs := grpc.NewServer(grpc.Creds(credentials.NewTLS(&tls.Config{ + GetCertificate: m.GetCertificate, + }))) proto.RegisterRoutesServer(gs, &Route{Server: s}) proto.RegisterTokensServer(gs, &Token{Server: s}) - l, err := tls.Listen("tcp", cfg.GRPCAddr, &tls.Config{ - GetCertificate: m.GetCertificate, - }) + l, err := net.Listen("tcp", cfg.GRPCAddr) if err != nil { return nil, err }