How to ignore SSL issues in axios or fetch?

Hi I am trying to send requests to my server which has a valid ssl certificate, but for some reason axios takes it as invalid, so axios does not allow me to send requests to my server’s api.

this is the error i get:

Error: Network Error

So I wonder if there is any way to make axios ignore the problem with the ssl and can send the requests in a normal way

this is my code:

try {
        const headers = {
            'Accept-Language': 'es-ES,es;q=0.8',
            "Content-Type": "application/x-www-form-urlencoded",
            "Accept": "application/json",
        };
        axios.get("https://URLtoMySERVER", {}, headers)
        .then(response => {
             console.log(response)
             const posts = response.data;
             console.log(posts)}
        ).catch(function(error) {
             console.log("error", error);
        });
 } catch (error) {
        console.log('err', error);
   }

Hi

Does it work without complaint from Chrome or another browser on the Android device?

If you test the certificate with SSL Server Test (Powered by Qualys SSL Labs) does it find any problems?

Are you able to get a more detailed error message? e.g. using adb logcat?

Hello, thanks for answering, this is the test of my certificate:

I don’t know the adb logcat but I will see if I can use it. But meanwhile I imagine it has something to do with the result of the certified test that does not work with axios

The incomplete certificate chain could be a problem.

See the following for some adb logcat hints:
https://docs.expo.io/versions/latest/workflow/logging/#view-logs-from-android-device-or-emulator

Should I change my server’s ssl certificate?, do the"let’s encrypt" certificates works well with axios?

If the problem is just with the certificate chain you probably just need to install an intermediate CA certificate in your web server. You would get it from the people who you got the certificate from.

You could send them a screenshot of the section of the test that shows the certificate chain and they should be able to tell you what to do. (Or they probably have a FAQ section on their site that will say what to do based on the web server you’re using.)

Let’s Encrypt should work fine, but your current certificate probably should too as long as your phone knows and trusts the CA and your certificate chain is correctly configured.

I changed my certificate for one of lets encrypt and the problem was solved axios requests already work without problem, but let’s encrypt remains the overall rating “B”

Thank you.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.