在本机中做出反应时忽略Ssl证书验证

时间:2017-10-13 12:07:15

标签: android ssl react-native ssl-certificate fetch

我正在开发一个应用程序,它使用rest api将其连接到数据库并且我的服务器具有SSL证书,当我尝试发送请求时,我的反应原生应用程序显示此error msg是否存在一种在Android的反应原生中禁用SSl验证的方法。

如果有人知道,请帮助。

1 个答案:

答案 0 :(得分:1)

此解决方案在 Android 上对我有用:

安装包:npm install --save rn-fetch-blob

并将此代码粘贴到您的 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()
相关问题