Skip to content

Commit

Permalink
Do not create PeerHealth new client without credentials
Browse files Browse the repository at this point in the history
Currently if peerhealth.NewClient is called with no
credentials.TransportCredentials it uses a DialOption which disables
transport security for this ClientConn.

Considering also the in the current code base it is not possible to
reach this point without valid credentials, this commit removes the
usage of such DialOption and returns with error instead for security
reasons.

Signed-off-by: Carlo Lobrano <[email protected]>
  • Loading branch information
clobrano committed Oct 26, 2023
1 parent 9d427a3 commit 247562e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/peerhealth/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package peerhealth

import (
"context"
"fmt"
"time"

"github.com/go-logr/logr"
Expand All @@ -22,7 +23,7 @@ func NewClient(serverAddr string, peerDialTimeout time.Duration, log logr.Logger
if clientCreds != nil {
opts = append(opts, grpc.WithTransportCredentials(clientCreds))
} else {
opts = append(opts, grpc.WithInsecure())
return nil, fmt.Errorf("client credential is nil")
}

// this option implies WithBlock()
Expand Down

0 comments on commit 247562e

Please sign in to comment.