4

On local testing server url have ssl certificate error so i have to disable ssl check. I have read many solutions on stackoverflow none of them helped. Problem is i can't make any change on server. So i want to know how to disable ssl check or is there any other api like fetch api or Retrofit for react native.?
My fetch api code as follows

fetch('https://example.com/logincheck', {
  method: 'post',
  headers: {
    'Accept': 'application/json, text/plain,',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "username" :"usrname",
  })
})
  .then(response =>  response.json())
  .then(responseobj => {
    this.setState({

    });
    console.log("login status:",responseobj.success);


  })
  .catch((error) => {
      console.error(error);
    });
Shibin Raju Mathew
  • 920
  • 4
  • 18
  • 41
  • "url have ssl error so i have to disable ssl check". this is **ABSOLUTELY NOT** the way to go. Fix the TLS problem, do not remove the check. And if you explained a little more about your problem people could have helped you with solutions. – Patrick Mevzek Jul 02 '18 at 15:00
  • Actually i have to use local server and no permission to change ssl certificate. In such case i have to ignore ssl check none of the solutions worked. Similar things done using Retrofit in android but not supporting reactnative – Shibin Raju Mathew Jul 02 '18 at 16:16
  • Please check https://stackoverflow.com/questions/15254976/how-do-i-use-the-node-js-request-module-to-make-an-ssl-call-with-my-own-certific – Dipin Raj C Jul 03 '18 at 06:41

2 Answers2

7

Now to bypass ssl certificate issue.. rn-fetch-blob released. Anyone searching for updated answer please use this answer and check the

rn-fetch-blob

package. To connect a server with self-signed certification, you need to add trusty to config explicitly

RNFetchBlob.config({
  trusty : true
})
.fetch('GET', 'https://example.com')
.then((resp) => {
  // ...
})
Shibin Raju Mathew
  • 920
  • 4
  • 18
  • 41
1

I think you are using self signed certificate that's why this problem so instead of self certificate use free ssl refer the following link for further information

self-signed certificate

I'm not suggesting disable the ssl check because this is not a good practice. So please suggest administrator to change self certificate to free ssl. I think you got the answer.