React native with self signed certificates on M1 chip MacOS

209 Views Asked by At

The below is my code for Webservices call, which works fine on both iOS and Android. But for API calls where self signed certificate is used, this does not work. I am using macOS with M1 chip.

To fix this, I used the steps mentioned in https://itnext.io/react-native-security-ssl-pinning-cde086210d58:

let dataToSend = {username: "rider1" ,password: "password"};
axios.post('https://my_domain:11443/websrc/api/v1.0/auth/login', dataToSend)
.then(function (response) {
    if (response.status === 200) {
        console.log(response.data);
    } else {
        console.log('Please check your email id or password');
    }
})
.catch(function (error) {
    console.log(error)
});

Output for Android :

Goes to the catch block of API call and returns error [Error: Network Error]

Output for iOS :

A splash screen appears and the app crashes immediately.

I am new to react-native. Any solutions are welcome.

0

There are 0 best solutions below