From 1475cf61ee464f69c67796445ba926a1ea65bd87 Mon Sep 17 00:00:00 2001 From: Adam Chalmers Date: Wed, 11 Nov 2020 12:17:14 -0600 Subject: [PATCH] TUN-3534: Specific error message when credentials file is a .pem not .json --- cmd/cloudflared/tunnel/subcommand_context.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/cloudflared/tunnel/subcommand_context.go b/cmd/cloudflared/tunnel/subcommand_context.go index 6f3cca20..130f4fa6 100644 --- a/cmd/cloudflared/tunnel/subcommand_context.go +++ b/cmd/cloudflared/tunnel/subcommand_context.go @@ -120,6 +120,12 @@ func (sc *subcommandContext) readTunnelCredentials(tunnelID uuid.UUID) (*pogs.Tu var auth pogs.TunnelAuth if err = json.Unmarshal(body, &auth); err != nil { + if strings.HasSuffix(filePath, ".pem") { + return nil, fmt.Errorf("The tunnel credentials file should be .json but you gave a .pem. "+ + "The tunnel credentials file was originally created by `cloudflared tunnel create` and named %s.json."+ + "You may have accidentally used the filepath to cert.pem, which is generated by `cloudflared tunnel "+ + "login`.", tunnelID) + } return nil, errInvalidJSONCredential{path: filePath, err: err} } return &auth, nil