TUN-3534: Specific error message when credentials file is a .pem not .json

This commit is contained in:
Adam Chalmers 2020-11-11 12:17:14 -06:00
parent ebc003d478
commit 1475cf61ee
1 changed files with 6 additions and 0 deletions

View File

@ -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