This is an automated email from the ASF dual-hosted git repository.
iuliana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-client.git
The following commit(s) were added to refs/heads/master by this push:
new 3c46cb8 Suggests --skipSslChecks if CLI 509 error encountered
new 8a2c9c0 Merge pull request #98 from
nakomis/better-error-for-x509-not-trusted
3c46cb8 is described below
commit 3c46cb8c8ecf777c7302e37fa51072fca6a8eb83
Author: Martin Harris <[email protected]>
AuthorDate: Mon Jul 10 16:13:00 2023 +0100
Suggests --skipSslChecks if CLI 509 error encountered
---
cli/commands/login.go | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/cli/commands/login.go b/cli/commands/login.go
index 0fcfb2a..9186c80 100644
--- a/cli/commands/login.go
+++ b/cli/commands/login.go
@@ -24,6 +24,7 @@ import (
"errors"
"fmt"
"net/http"
+ "net/url"
"os"
"strings"
"syscall"
@@ -34,7 +35,7 @@ import (
"github.com/apache/brooklyn-client/cli/io"
"github.com/apache/brooklyn-client/cli/net"
"github.com/apache/brooklyn-client/cli/scope"
- "github.com/urfave/cli/v2"
+ cli "github.com/urfave/cli/v2"
"golang.org/x/crypto/ssh/terminal"
)
@@ -175,6 +176,20 @@ func (cmd *Login) Run(scope scope.Scope, c *cli.Context) {
if code == http.StatusUnauthorized {
err = errors.New("Unauthorized")
}
+ switch err.(type) {
+ case *url.Error:
+ urlError := err.(*url.Error)
+ if !cmd.network.SkipSslChecks &&
strings.Contains(fmt.Sprint(urlError.Err), "x509") {
+ message := fmt.Sprint(urlError) + `
+
+This may be due to a missing or untrusted certificate in use by the server.
+If this is expected and you trust the connection to the server, you can ignore
this with:
+
+ br login --skipSslChecks ` + cmd.network.BrooklynUrl + `
+`
+ err = errors.New(message)
+ }
+ }
error_handler.ErrorExit(err)
}
fmt.Printf("Connected to Brooklyn version %s at %s\n",
loginVersion.Version, cmd.network.BrooklynUrl)