Skip to content

Commit

Permalink
Merge pull request kubernetes#126930 from Ruddickmg/patch-1
Browse files Browse the repository at this point in the history
kmsv2: set authority to localhost
  • Loading branch information
k8s-ci-robot authored Aug 28, 2024
2 parents ad87920 + 618ca85 commit 95b3fe9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func NewGRPCService(ctx context.Context, endpoint, providerName string, callTime
s := &gRPCService{callTimeout: callTimeout}
s.connection, err = grpc.Dial(
addr,
grpc.WithAuthority("localhost"),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultCallOptions(grpc.WaitForReady(true)),
grpc.WithContextDialer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"

"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -61,7 +62,16 @@ type Base64Plugin struct {

// NewBase64Plugin is a constructor for Base64Plugin.
func NewBase64Plugin(t testing.TB, socketPath string) *Base64Plugin {
server := grpc.NewServer()
server := grpc.NewServer(
grpc.UnaryInterceptor(
func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
if val := metadata.ValueFromIncomingContext(ctx, ":authority"); len(val) != 1 || val[0] != "localhost" {
t.Errorf("wanted localhost authority, got: %v", val)
}
return handler(ctx, req)
},
),
)
result := &Base64Plugin{
grpcServer: server,
mu: &sync.Mutex{},
Expand Down

0 comments on commit 95b3fe9

Please # to comment.