如何在React Native XMLHttpRequest API或Fetch Api中禁用ssl检查?

编程入门 行业动态 更新时间:2024-10-11 23:24:46
本文介绍了如何在React Native XMLHttpRequest API或Fetch Api中禁用ssl检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在本地测试服务器上,URL具有ssl证书错误,因此我必须禁用ssl检查.我已经阅读了许多关于stackoverflow的解决方案,但都无济于事.问题是我无法在服务器上进行任何更改.所以我想知道如何禁用ssl检查,或者是否有其他其他api,例如fetch api或Retrofit来进行本机反应?? 我的提取api代码如下

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('example/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); });

推荐答案

现在可以绕过ssl证书问题..rn-fetch-blob已发布.搜索更新答案的任何人,请使用此答案并检查

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

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', 'example') .then((resp) => { // ... })

更多推荐

如何在React Native XMLHttpRequest API或Fetch Api中禁用ssl检查?

本文发布于:2023-11-24 19:46:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626571.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   Native   React   XMLHttpRequest   ssl

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!