Skip to content

Commit

Permalink
Ignore certificate in insecure mode (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Bączek authored Sep 16, 2022
1 parent ccf69b5 commit b2712ea
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/pkg/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/jhump/protoreflect/grpcreflect"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
reflectpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
)
Expand Down Expand Up @@ -63,7 +63,12 @@ func (c *Client) Connect(headers []string) error {

dialOptions := []grpc.DialOption{grpc.WithBlock()}
if c.insecure {
dialOptions = append(dialOptions, grpc.WithTransportCredentials(insecure.NewCredentials()))
tlsConf, err := grpcurl.ClientTLSConfig(c.insecure, "", "", "")
if err != nil {
return fmt.Errorf("failed to create TLS config: %v", err)
}
var creds = credentials.NewTLS(tlsConf)
dialOptions = append(dialOptions, grpc.WithTransportCredentials(creds))
}

conn, err := grpc.DialContext(ctx, c.host, dialOptions...)
Expand Down

0 comments on commit b2712ea

Please sign in to comment.