SSL certificate and React Native Axios

Viewed 1651

I'm using Axios in react native application to make calls to HTTPS API, but I have a problem with the SSL verification. for that, I want to ask if there is any way to (ignore) the SSL verification using Axios.

note that it's a GoDaddy certificate and I cannot change it.

1 Answers

Add this configuration to axios and set rejectUnauthorized to false:

// At instance level
const instance = axios.create({
  httpsAgent: new https.Agent({  
    rejectUnauthorized: false
  })
});
instance.get('https://something.com/foo');

// At request level
const agent = new https.Agent({  
  rejectUnauthorized: false
});
axios.get('https://something.com/foo', { httpsAgent: agent });
Related