MacOS 开发 — http请求数据失败

Xcode中http 请求失败对应的错误提示如下:

2019-03-18 14:56:32.687068+0800 Afinia Debug[10987:469562] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
2019-03-18 14:56:32.687124+0800 Afinia Debug[10987:469562] Cannot start load of Task <6EE5455B-6B4E-4452-A4EA-2DD76EA8DBB9>.<1> since it does not conform to ATS policy
2019-03-18 14:56:32.687268+0800 Afinia Debug[10987:469628] Task <6EE5455B-6B4E-4452-A4EA-2DD76EA8DBB9>.<1> finished with error - code: -1022
2019-03-18 14:56:32.689733+0800 Afinia Debug[10987:469524] Task <6EE5455B-6B4E-4452-A4EA-2DD76EA8DBB9>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection., NSErrorFailingURLStringKey=http://afinia.s3-website-us-west-1.amazonaws.com/AfiniaV250.LKD, NSErrorFailingURLKey=http://afinia.s3-website-us-west-1.amazonaws.com/AfiniaV250.LKD, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDownloadTask <6EE5455B-6B4E-4452-A4EA-2DD76EA8DBB9>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <6EE5455B-6B4E-4452-A4EA-2DD76EA8DBB9>.<1>, NSUnderlyingError=0x600000f54180 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}} [-1022]
[!]error ===> TT_ERROR_CONFIG_READ_VALUE_KEY[root:Global key:ModelColor] (ReadConfigValue)

那么如何设置呢?
首先需要在 info.plist 文件中选择 App Transport Security Settings 添加 Allow Arbitrary Loads和Allow Arbitrary Loads in Web Content 设置为YES
在这里插入图片描述
其次需要注意的是,必须缇娜家Exception Domains,设置内容如上图所示。
切:NSExceptionMinimumTLSVersion 必须必设置为TLSv1.0 否则 错误仍然存在。

PS: 注意单词的拼写。

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值