4

I am working on an app that uses rest API to get it connected to a database and my server has an SSL certificate and from my react native app when I am trying to send the request it shows this error msg is there is a way to disable SSL verification in react native for android.

If anyone knows, help.

javapedia.net
  • 2,531
  • 4
  • 25
  • 50
Husain Khanbahadur
  • 479
  • 1
  • 8
  • 22
  • I think you can refer to [this question](https://stackoverflow.com/questions/36289125/react-native-fetch-from-https-server-with-self-signed-certificate) – Alexander Vitanov Oct 13 '17 at 13:48
  • Possible duplicate of [React-native fetch() from https server with self-signed certificate](https://stackoverflow.com/questions/36289125/react-native-fetch-from-https-server-with-self-signed-certificate) – ZedTuX Jul 11 '18 at 04:24

1 Answers1

2

This solution worked for me on Android:

install package : npm install --save rn-fetch-blob

and paste this code in your index.js

import RNFetchBlob from 'rn-fetch-blob';

AppRegistry.registerComponent(appName, () => App);
const Fetch = RNFetchBlob.polyfill.Fetch
  // replace built-in fetch
 window.fetch = new Fetch({
 // enable this option so that the response data conversion handled automatically
  auto : true,
  // when receiving response data, the module will match its Content-Type header
  // with strings in this array. If it contains any one of string in this array, 
 // the response body will be considered as binary data and the data will be stored
 // in file system instead of in memory.
 // By default, it only store response data to file system when Content-Type 
 // contains string `application/octet`.
  binaryContentTypes : [
  'image/',
  'video/',
  'audio/',
  'foo/',
   ],
   trusty : true
  }).build()
sver
  • 866
  • 1
  • 19
  • 44