usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
27.34k stars 1.26k forks source link

Bruno CLI returning unsupported when running a request with a specified client certificate #3485

Open je223xa opened 1 day ago

je223xa commented 1 day ago

I have checked the following:

Describe the bug

I found 2730, which says it should be possible to provide the CLI with certificates. But for me it is not working at all. When I make the request (or try to) the cli shows me

> bru run --env mycollection
Running Folder Recursively

GetBearerToken (unsupported)

The moment I take out the clientCertificate from bruno.json, the request is executed

GetBearerToken (403 Forbidden) - 591 ms
   ✕ assert: res.status: eq 200
      expected 403 to equal 200
   ✕ assert: res.body.token_type: eq Bearer
      expected undefined to equal 'Bearer'

Is there any plan to support this? What is missing for this to work in the CLI? I would think everything is there, maybe my configuration files are wrong?

Thanks for all the awesome work, Bruno is an amazing tool and the more I work with it, the more I like it!

.bru file to reproduce the bug

{
  "version": "1",
  "name": "mycollection",
  "type": "collection",
  "ignore": [
    "node_modules",
    ".git"
  ],
  "clientCertificates": {
    "enabled": true,
    "certs": [
      {
        "domain": "ssobroker.domain.com",
        "type": "pfx",
        "pfxFilePath": "path/to/cert.p12",
        "passphrase": "***"
      }
    ]
  }
}

Screenshots/Live demo link

My GetBearerToken request:

meta {
  name: GetBearerToken
  type: http
  seq: 1
}

post {
  url: https://ssobroker.domain.com:10443/as/token.oauth2
  body: formUrlEncoded
  auth: none
}

body:form-urlencoded {
  grant_type: client_credentials
  client_id: {{ssoClientId}}
  scope: {{ssoScope}}
}

vars:post-response {
  token: res.body.access_token
}

assert {
  res.status: eq 200
  res.body.token_type: eq Bearer
}
je223xa commented 1 day ago

Using key and certificate on its own fixed it, so I guess only keystores currently are not supported in CLI.

I did have problems to extract the key from it manually as well though, some problem with the encryption algorithms being too old. I am not too familiar with the topic, but it might be that that was the reason for the Bruno error I saw