Huachao / vscode-restclient

REST Client Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=humao.rest-client
MIT License
5.24k stars 436 forks source link

How to configure path of certificate files relative to the http file #1238

Open meakgoz opened 8 months ago

meakgoz commented 8 months ago

Hi Huachao and the community,

I managed to get the JWT token with certificate. It is working when I give the full path, or relative to the workspace root.

I have the http file in here: /Users/<myUserId>/git/<projectName>/backend/test/manual-requests/requests.http and certificate in here: /Users/<myUserId>/git/<projectName>/backend/test/manual-requests/cert.pem and key: /Users/<myUserId>/git/<projectName>/backend/test/manual-requests/key.pem

Then, this configuration works:

  "rest-client.certificates": {
    "mydomain.com": {
      "cert": "/Users/<myUserId>/git/<projectName>/backend/test/manual-requests/cert.pem",
      "key": "/Users/<myUserId>/git/<projectName>/backend/test/manual-requests/key.pem"
    }
  },

Or this one also works:

  "rest-client.certificates": {
    "mydomain.com": {
      "cert": "./backend/test/manual-requests/cert.pem",
      "key": "./backend/test/manual-requests/key.pem"
    }
  }

However, I get error when I try the path relative to the http file:

  "rest-client.certificates": {
    "mydomain.com": {
      "cert": "./cert.pem",
      "key": "./key.pem"
    }
  }

I get the following error: Certificate path ./key.pem doesn't exist, please make sure it exists.

How can I configure path of certificate files relative to the http file?

rufreakde commented 8 months ago

"./backend/test/manual-requests/key.pem" -> "backend/test/manual-requests/key.pem" worked for me.

PS: I switched to the p12 certificate structure as it was simpler to use and maintain. And here I am not sure how to maintain the passphrase in ENV.

meakgoz commented 8 months ago

Hi @rufreakde, thank you for your answer. Unfortunately, following your suggestion did not do the trick for me. In fact, this "./backend/test/manual-requests/key.pem" is working for me, and this path is actually relative to the workspace. The problem is, "cert": "./cert.pem" or "cert": "cert.pem" does not work, where this is relative to the test.http file. In the documentation it states:

you need to set the certificates paths(absolute/relative to workspace/relative to current http file)

but could not make this work for me.

cplussharp commented 6 months ago

Some years ago a created this pull request #808 to allow TLS client certificates per request. Sadly it was never merged.