加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – iOS 5:https(ASIHTTPRequest)停止工作

发布时间:2020-12-16 03:12:06 所属栏目:百科 来源:网络整理
导读:我有一个使用ASIHTTPRequest的应用程序. 我用iOS 5(sdk:5.0 / xcode:4.2 Build 4D199)重新编译我的应用程序,https连接失败并显示错误消息(与禁用https相同的调用正常): Error Domain=ASIHTTPRequestErrorDomain Code=1 "A connection failure occurred" U
我有一个使用ASIHTTPRequest的应用程序.

我用iOS 5(sdk:5.0 / xcode:4.2 Build 4D199)重新编译我的应用程序,https连接失败并显示错误消息(与禁用https相同的调用正常):

Error Domain=ASIHTTPRequestErrorDomain Code=1 "A connection failure occurred" UserInfo=0xa8e66e0 {NSUnderlyingError=0xa8ac6c0 "The operation couldn’t be completed. (OSStatus error -9844.)",NSLocalizedDescription=A connection failure occurred}

启用调试日志:

[STATUS] Starting asynchronous request <ASIFormDataRequest: 0xd96fc00>

[CONNECTION] Request <ASIFormDataRequest: 0xd96fc00> will not use a persistent connection

[STATUS] Request <ASIFormDataRequest: 0xd96fc00>: Failed

[CONNECTION] Request #(null) failed and will invalidate connection #(null)

我发现这个相关帖子:
https://devforums.apple.com/message/537440#537440
这可以解释我的问题.

基于iOS 5喜欢TLS 1.2的想法,我尝试在AIHTTPRequest.m中更改设置kCFStreamSocketSecurityLevelTLSv1

NSDictionary *sslProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
                                     [NSNumber numberWithBool:YES],kCFStreamSSLAllowsExpiredCertificates,[NSNumber numberWithBool:YES],kCFStreamSSLAllowsAnyRoot,[NSNumber numberWithBool:NO],kCFStreamSSLValidatesCertificateChain,kCFNull,kCFStreamSSLPeerName,kCFStreamSocketSecurityLevelTLSv1,kCFStreamSSLLevel,// my modif
                                     nil];

没有成功.也许我的修改是不正确的?

细节:

>我的ARC被禁用了
>我使用libz.1.2.5.dylib
>一周前我更新了ASIHTTPRequest.

我不知道问题是证书故事(如TLS版本)还是其他内容.

任何帮助/想法是欢迎!

解决方法

这是最终的解决方案:

https://developer.apple.com/library/ios/#technotes/tn2287/_index.html#//apple_ref/doc/uid/DTS40011309

NSDictionary *sslProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
                                       [NSNumber numberWithBool:YES],@"kCFStreamSocketSecurityLevelTLSv1_0SSLv3",nil];

添加此参数:

@"kCFStreamSocketSecurityLevelTLSv1_0SSLv3",

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读