Skip to content

Commit

Permalink
[#417] rpc/client: Do not use deprecated code elements
Browse files Browse the repository at this point in the history
`grpc.WithInsecure` has been marked as deprecated in earlier releases of
`google.golang.org/grpc`.

Use `google.golang.org/grpc/credentials/insecure` package instead as
recommended.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
  • Loading branch information
Leonard Lyubich authored and cthulhu-rider committed Sep 23, 2022
1 parent 49bf6b2 commit 504e427
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions rpc/client/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/rpc/grpc"
grpcstd "google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)

func (c *Client) createGRPCClient() (err error) {
Expand Down Expand Up @@ -38,19 +39,17 @@ func (c *Client) openGRPCConn() error {
return errInvalidEndpoint
}

var err error

var credOpt grpcstd.DialOption
var creds credentials.TransportCredentials

if c.tlsCfg != nil {
creds := credentials.NewTLS(c.tlsCfg)
credOpt = grpcstd.WithTransportCredentials(creds)
creds = credentials.NewTLS(c.tlsCfg)
} else {
credOpt = grpcstd.WithInsecure()
creds = insecure.NewCredentials()
}

dialCtx, cancel := context.WithTimeout(context.Background(), c.dialTimeout)
c.conn, err = grpcstd.DialContext(dialCtx, c.addr, credOpt)
var err error
c.conn, err = grpcstd.DialContext(dialCtx, c.addr, grpcstd.WithTransportCredentials(creds))
cancel()

return err
Expand Down

0 comments on commit 504e427

Please sign in to comment.