From 9ffad7fcebe57fedcd71688b3bd1e33bff8d8692 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 31 Aug 2020 19:27:49 -0700 Subject: [PATCH] discard empty endpoint in crypto kes introduced in 18725679c4f581683362ed814c98baa1fb8c53c0 --- cmd/crypto/config.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/crypto/config.go b/cmd/crypto/config.go index 5761c254d..09a0b314a 100644 --- a/cmd/crypto/config.go +++ b/cmd/crypto/config.go @@ -222,6 +222,9 @@ func LookupKesConfig(kvs config.KVS) (KesConfig, error) { endpointStr := env.Get(EnvKMSKesEndpoint, kvs.Get(KMSKesEndpoint)) var endpoints []string for _, endpoint := range strings.Split(endpointStr, ",") { + if strings.TrimSpace(endpoint) == "" { + continue + } if !ellipses.HasEllipses(endpoint) { endpoints = append(endpoints, endpoint) continue @@ -234,6 +237,9 @@ func LookupKesConfig(kvs config.KVS) (KesConfig, error) { endpoints = append(endpoints, p.Expand()...) } } + if len(endpoints) == 0 { + return kesCfg, nil + } randNum := rand.Intn(len(endpoints) + 1) // We add 1 b/c len(endpoints) may be 0: See: rand.Intn docs kesCfg.Endpoint = make([]string, len(endpoints))