From 88902b55b7363c500cf8ace8dfacc2d5776c4e62 Mon Sep 17 00:00:00 2001 From: Alex Aizman Date: Tue, 20 Aug 2024 10:21:42 -0400 Subject: [PATCH] CLI: tls config validation - make it a warning Signed-off-by: Alex Aizman --- cmd/cli/cli/init.go | 8 ++------ cmd/cli/config/config.go | 10 ++++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cmd/cli/cli/init.go b/cmd/cli/cli/init.go index afe15a54502..e2aa9ba9953 100644 --- a/cmd/cli/cli/init.go +++ b/cmd/cli/cli/init.go @@ -56,9 +56,7 @@ func Init(args []string) (err error) { UA: ua, } if cos.IsHTTPS(clusterURL) { - if err = cfg.ValidateTLS(); err != nil { - return err - } + cfg.WarnTLS("aistore at " + clusterURL) clientTLS = cmn.NewClientTLS(cargs, sargs) apiBP.Client = clientTLS } else { @@ -74,9 +72,7 @@ func Init(args []string) (err error) { } if cos.IsHTTPS(authnURL) { if clientTLS == nil { - if err = cfg.ValidateTLS(); err != nil { - return err - } + cfg.WarnTLS("AuthN at " + authnURL) clientTLS = cmn.NewClientTLS(cargs, sargs) } authParams.Client = clientTLS diff --git a/cmd/cli/config/config.go b/cmd/cli/config/config.go index 7eb2290b356..58a7a804f86 100644 --- a/cmd/cli/config/config.go +++ b/cmd/cli/config/config.go @@ -173,16 +173,18 @@ func (c *Config) validate() (err error) { return nil } -func (c *Config) ValidateTLS() (err error) { - err = cos.Stat(c.Cluster.Certificate) +func (c *Config) WarnTLS(server string) { + err := cos.Stat(c.Cluster.Certificate) if err == nil { err = cos.Stat(c.Cluster.CertKey) } if err == nil { - return nil + return } path := filepath.Join(ConfigDir, fname.CliConfig) - return fmt.Errorf("CLI config at %s: invalid public/private key pair (%q,%q): %v", + + fmt.Fprintln(os.Stderr, "Warning: CLI may have a problem communicating with "+server+" - CLI config at") + fmt.Fprintf(os.Stderr, "%s contains invalid public/private key pair (%q,%q), err: %v\n\n", path, c.Cluster.Certificate, c.Cluster.CertKey, err) }