ReactNative-https证书无效

news/2024/7/12 3:18:50 标签: Https, https证书无效, reactnative

iOS解决:


在该文件中,添加过滤证书的代理方法。

-(void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler {
  
  NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling;
  __block NSURLCredential *credential = nil;
  
  if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
    credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
    if (credential) {
      disposition = NSURLSessionAuthChallengeUseCredential;
    } else {
      disposition = NSURLSessionAuthChallengePerformDefaultHandling;
    }
  } else {
    disposition = NSURLSessionAuthChallengePerformDefaultHandling;
  }
  
  if (completionHandler) {
    completionHandler(disposition, credential);
  }
}


http://www.niftyadmin.cn/n/704368.html

相关文章

larave5.5 配置邮箱 邮箱激活

转载于:https://blog.51cto.com/13708834/2173917

Could not symlink ... is not writable.

使用HomeBrew,例如:$ brew link cmake,会出现一下错误。 Could not symlink share/man/man7/cmake-buildsystem.7 /usr/local/share/man/man7 is not writable. 解决方法: 先执行 $ sudo chown -R $(whoami):admin /usr/local/sha…

spark实现分页查询hbase

第一种: import org.apache.hadoop.hbase.io.ImmutableBytesWritableimport org.apache.spark.{SparkConf, SparkContext}import org.apache.hadoop.hbase.mapreduce.TableInputFormatimport org.apache.hadoop.hbase.protobuf.ProtobufUtilimport org.apache.hadoo…

react-native无法运行多个应用,修改端口

当用react-native创建应用并运行,两个以上模拟器会报错,因为本地服务默认是8081端口,所以需要将其他的应用端口修改,防止端口冲突。 1.修改JS端,找到server.js文件, 你的项目名称/node_modules/react-nativ…

PageOfficeV4.0 动态生成WORD文件

2019独角兽企业重金招聘Python工程师标准>>> PageOffice 组件提供的接口和对象都简洁高效,开发效率很高。不仅支持从一个空白的Word生成文件,还可以对现有的word模板做数据填充,还可以把多个word模板插入到一个word模板中不同的位…

Native module cannot be null

情况一 原因: 在react native 中,声明了某个module,但是原生没有此module,导致错误。 如:在js中声明了p2pRTC, var p2pRTC NativeModules.P2PRTCModule; 解决: 原生实现该Module,或…

ReactNative 事件监听

一、ReactNative内部事件通知 1.引入头文件 import { DeviceEventEmitter } from react-native;2.发送方 发送通知DeviceEventEmitter.emit(通知名称);3.接收方 接收通知 componentDidMount() { this.subscription DeviceEventEmitter.addListener(通知名称, (params) > {}…

webpack雪碧图的实现

步骤一 安装webpack-spritesmith npm install --save-dev webpack-spritesmith 复制代码步骤二 在webpack.config.js添加代码 var path require(path); var SpritesmithPlugin require(webpack-spritesmith); module.exports {// ...module: {rules: [{test: /\.styl$/, use…