From a4683c0b7859f5efdba92422890ef329cbf9054a Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Tue, 20 Apr 2021 12:21:00 +0300 Subject: [PATCH] drop AuthTLS option and use client TLSConfig option Signed-off-by: Vasiliy Tolstov --- grpc.go | 11 ++++------- options.go | 11 ----------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/grpc.go b/grpc.go index a7899ab..cd6c20b 100644 --- a/grpc.go +++ b/grpc.go @@ -35,13 +35,10 @@ type grpcClient struct { // secure returns the dial option for whether its a secure or insecure connection func (g *grpcClient) secure(addr string) grpc.DialOption { // first we check if theres'a tls config - if g.opts.Context != nil { - if v := g.opts.Context.Value(tlsAuth{}); v != nil { - tls := v.(*tls.Config) - creds := credentials.NewTLS(tls) - // return tls config if it exists - return grpc.WithTransportCredentials(creds) - } + if g.opts.TLSConfig != nil { + creds := credentials.NewTLS(g.opts.TLSConfig) + // return tls config if it exists + return grpc.WithTransportCredentials(creds) } // default config diff --git a/options.go b/options.go index a4d5511..4745089 100644 --- a/options.go +++ b/options.go @@ -3,7 +3,6 @@ package grpc import ( "context" - "crypto/tls" "github.com/unistack-org/micro/v3/client" "google.golang.org/grpc" @@ -72,16 +71,6 @@ func Codec(contentType string, c encoding.Codec) client.Option { } } -// AuthTLS should be used to setup a secure authentication using TLS -func AuthTLS(t *tls.Config) client.Option { - return func(o *client.Options) { - if o.Context == nil { - o.Context = context.Background() - } - o.Context = context.WithValue(o.Context, tlsAuth{}, t) - } -} - // // MaxRecvMsgSize set the maximum size of message that client can receive. //