ASIHTTPRequestErrorDomain code 1
来源:互联网 发布:打开照片的软件 编辑:程序博客网 时间:2024/05/22 02:19
用域名连,不行。查了下有人解决了:
http://stackoverflow.com/questions/8538449/asihttprequesterrordomain-code-1
0down votefavorite
In my app, i'm trying to connect to a IIS server to access some servers. Whe i run the app in iOS 4 or earlier the connection works fine, but wen i run in iOS 5, the connection retorn this erro:
Error Domain=ASIHTTPRequestErrorDomain Code=1 "A connection failure occurred" UserInfo=0x6b601d0 {NSUnderlyingError=0x6b5fe20 "The operation couldn’t be completed. (OSStatus error -9836.)", NSLocalizedDescription=A connection failure occurred}
this is the code that i call.
self.currentRequest = [ASIHTTPRequest requestWithURL:url];[self.currentRequest setValidatesSecureCertificate:NO];[self.currentRequest setDelegate:self];[self.currentRequest setUsername:credentials.login];[self.currentRequest setPassword:credentials.password];[self.currentRequest setDomain:@"CORP"];[self.currentRequest setUseHTTPVersionOne:YES];[self.currentRequest setTimeOutSeconds:120];[self.currentRequest startAsynchronous];
Samebody have an idea why this is happening?
Thank's
1 Answer
-9836 is a bad protocol error. It's probably due to iOS 5's implementation of TLS being upgraded to TLS 1.2. If TLS 1.2 isn't supported by the server it may terminate the handshake and fail to downgrade to a supported protocol level.
In ASIHTTPRequest.m change to the following in - (void)startRequest
//// Handle SSL certificate settings//if([[[[self url] scheme] lowercaseString] isEqualToString:@"https"]) { NSDictionary *sslProperties = [[NSDictionary alloc] initWithObjectsAndKeys: @"kCFStreamSocketSecurityLevelTLSv1_0SSLv3", (NSString *)kCFStreamSSLLevel, nil]; CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertySSLSettings, (CFTypeRef)sslProperties); // Tell CFNetwork not to validate SSL certificates if (![self validatesSecureCertificate]) { // see: http://iphonedevelopment.blogspot.com/2010/05/nsstream-tcp-and-ssl.html NSDictionary *sslProperties = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredCertificates, [NSNumber numberWithBool:YES], kCFStreamSSLAllowsAnyRoot, [NSNumber numberWithBool:NO], kCFStreamSSLValidatesCertificateChain, kCFNull,kCFStreamSSLPeerName, @"kCFStreamSocketSecurityLevelTLSv1_0SSLv3", (NSString *)kCFStreamSSLLevel, nil]; CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertySSLSettings, (CFTypeRef)sslProperties); } // Tell CFNetwork to use a client certificate if (clientCertificateIdentity) { NSMutableDictionary *sslProperties = [NSMutableDictionary dictionaryWithCapacity:2]; NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[clientCertificates count]+1]; // The first object in the array is our SecIdentityRef [certificates addObject:(id)clientCertificateIdentity]; // If we've added any additional certificates, add them too for (id cert in clientCertificates) { [certificates addObject:cert]; } [sslProperties setObject:certificates forKey:(NSString *)kCFStreamSSLCertificates]; [sslProperties setObject:@"kCFStreamSocketSecurityLevelTLSv1_0SSLv3" forKey:(NSString *)kCFStreamSSLLevel]; CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertySSLSettings, sslProperties); }}
- ASIHTTPRequestErrorDomain code 1
- ASIHTTPRequestErrorDomain Code=8 解决办法
- Error Domain=ASIHTTPRequestErrorDomain Code=5 "Unable to create request (bad url?)" UserInfo=0x15f86
- Events Sample Code(1)
- quake3 code fragment [1]
- code complete(1)
- f code(1)
- TDI code 1
- USACO Solution Code(1)
- T-CODE(1)
- code review手记1
- code Kata NO.1
- bt code (1)
- Code for fun (1)
- Optimizing JavaScript Code - 1
- Appium_python code(1)
- Appium_Java code(1)
- code slot - SkipList - 1
- 为asp.net mvc创建可重用的ui组件
- Linux基础东西总结 以及比较有用的链接地址
- CF_137_div2_E_Decoding Genome 题解
- hdu 4288 五颗线段树
- CSS优化,如何写出高效整洁的CSS代码
- ASIHTTPRequestErrorDomain code 1
- 初始化下拉框
- Motorola Symbol MC3190开发问题
- 一个求21位花朵数的Java程序
- POI导出EXCEL经典实现
- MVC3换肤
- .net 求百分比
- C和C++几点区别
- java 遍历 map