本文介绍了AFNetworking 3.2.0'配置的安全策略只能应用于具有安全基本URL(即https)的管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我已将我的iOS应用的AFNetworking连播从3.1.0更新到了3.2.0.AFNetworking3.2.0出现类似以下问题,使应用程序崩溃

Recently I have updated my iOS App's AFNetworking pods from 3.1.0 to 3.2.0. AFNetworking3.2.0 Having issues like Crashing the app withe bellow error

Terminating app due to uncaught exception 'Invalid Security Policy', reason: 'A security policy configured with AFSSLPinningModeCertificate can only be applied on a manager with a secure base URL (i.e. https)'

Terminating app due to uncaught exception 'Invalid Security Policy', reason: 'A security policy configured withAFSSLPinningModeCertificatecan only be applied on a manager with a secure base URL (i.e. https)'

执行代码后,应用崩溃了

After Executing code then the app Crashed

Which is working fine when switch back to old version with AFNetworking_3.1.0 But crashing on 3.2.0

我还尝试 operation.securityPolicy.allowInvalidCertificates = YES; 但没用

请指导m,对于AFNetwrking3.2.0,我还有其他需要改进的地方.

Please guide m is there anything else I need to improve upon for AFNetwrking3.2.0.

推荐答案

查看以下Pull请求: https://github.com/AFNetworking/AFNetworking/pull/3687

Check out this Pull request: https://github.com/AFNetworking/AFNetworking/pull/3687

它清楚地提到,使用不安全的http 基本URL配置的AFHTTPSessionManager实例将引发异常.

It clearly mentions that AFHTTPSessionManager instance configured with an insecure http base URL will throw an exception.

要从3.2.0开始使用AFHTTPSessionManager,如果要设置使用AFSSLPinningModeCertificateAFSSLPinningModePublicKey

To use AFHTTPSessionManager from 3.2.0 onwards you'll have to switch to a secure https base URL if you are setting the security policy configured with AFSSLPinningModeCertificate or AFSSLPinningModePublicKey

这篇关于AFNetworking 3.2.0'配置的安全策略只能应用于具有安全基本URL(即https)的管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 23:16