Skip to content

Commit 1475cf6

Browse files
committed
TUN-3534: Specific error message when credentials file is a .pem not .json
1 parent ebc003d commit 1475cf6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cmd/cloudflared/tunnel/subcommand_context.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ func (sc *subcommandContext) readTunnelCredentials(tunnelID uuid.UUID) (*pogs.Tu
120120

121121
var auth pogs.TunnelAuth
122122
if err = json.Unmarshal(body, &auth); err != nil {
123+
if strings.HasSuffix(filePath, ".pem") {
124+
return nil, fmt.Errorf("The tunnel credentials file should be .json but you gave a .pem. "+
125+
"The tunnel credentials file was originally created by `cloudflared tunnel create` and named %s.json."+
126+
"You may have accidentally used the filepath to cert.pem, which is generated by `cloudflared tunnel "+
127+
"login`.", tunnelID)
128+
}
123129
return nil, errInvalidJSONCredential{path: filePath, err: err}
124130
}
125131
return &auth, nil

0 commit comments

Comments
 (0)