server: do ssl good
This commit is contained in:
parent
a224f2fe0c
commit
0f7b2dbaf0
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue