thunderclient / thunder-client-support

Thunder Client is a lightweight Rest API Client Extension for VS Code.
https://www.thunderclient.com
Other
3.64k stars 130 forks source link

How to allow self-signed certs with axios #1408

Closed dviljoen closed 11 months ago

dviljoen commented 11 months ago

Question: Just upgraded to 2.16.0 and request failed with "self-signed certificate" error. Switching to "got" http library works. How do I get axios to accept self-signed certs?

Are you using the free version/paid version/trial: Free version.

rangav commented 11 months ago

Hi @dviljoen

Are you using custom ssl certificates or is the issue with localhost ssl errors?

dviljoen commented 11 months ago

We are developing an API server and use self-signed certs for development purposes.

dviljoen commented 11 months ago

image

dviljoen commented 11 months ago

But with "got" client: image

rangav commented 11 months ago

can you confirm you are not using this right? - https://github.com/rangav/thunder-client-support#manual-ssl-certificates

rangav commented 11 months ago

You can test with axios yourself and see which config is working for you in the Post Request scripting.

sample script below:

const axios = require('axios');
var result = await axios.get("https://dvred:443/redapi/v1/setup_status");
console.log(result.data);

useful links https://www.codewithyou.com/blog/how-to-use-axios-to-handle-ssltls-certificate-verification-errors-in-nodejs https://github.com/rangav/thunder-client-support/blob/master/docs/filters.md#execute-requests

dviljoen commented 11 months ago

I don't understand the question about custom ssl vs. local host. It's neither. We generate a certificate for our api server. But we are the CA. It's self signed. That's the only issue. Just like you get the warning in a browser if you go to a self-signed cert on a web url. That's all I'm asking. How do I make axios do the thing that a browser can do when you click through the warning about a self-signed cert?

rangav commented 11 months ago

Ok got it.

please test this https://github.com/rangav/thunder-client-support/issues/1408#issuecomment-1812711518

rangav commented 11 months ago

Hi All, I made the small config changes to address this issue for axios.

Can you guys please update the extension to v2.16.1 and let me know if it's working or not?

dviljoen commented 11 months ago

Just tried with v2.16.1 and got the same error: "self-signed certificate" Sorry.

rangav commented 11 months ago

Thanks for testing.

I reverted default http library back to got. Please update to 2.16.2