React-native:自签名认证实现 使用经典获取:使用 rn-fetch-blob 获取:一个正常工作的解决方案是忽略认证,但这当然不安全

问题描述

您是否知道如何在 react-native 应用程序中使用 自签名认证 正确处理 fetch 调用

使用经典获取

TypeError: Request Failed

使用 rn-fetch-blob 获取

[Error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.]

一个正常工作的解决方案是忽略认证,但这当然不安全。

代码位于 index.js 文件应用程序中。

const Fetch = RNFetchBlob.polyfill.Fetch
window.fetch = new Fetch({
  trusty: true
}).build()

我查看了一个不同的帖子,例如 this !

解决方法

我使用 react-native-ssl-pinning,它与证书固定配合良好。

真正的问题来自服务器证书的错误安装。