在本地测试服务器上,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检查?
发布评论