server: do ssl good

This commit is contained in:
Cadey Ratio 2017-04-28 22:30:32 -07:00
parent a224f2fe0c
commit 0f7b2dbaf0
1 changed files with 5 additions and 4 deletions

View File

@ -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
}