React-Native,iOS跳过HTTPS的SSL证书认证(自签或者无认证)
iOS的解决办法:
RN依赖模块:React-RCTNetwork
文件:RCTHTTPRequestHandler.mm
在RCTHTTPRequestHandler.mm找到这句话#pragma mark - NSURLSession delegate
在这句话之后加入后面的方法:
// 解决IOS无法访问不受信任HTTPS服务器的问题 satrt
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
{
completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
}
// 解决IOS无法访问不受信任HTTPS服务器的问题 end