获取CFNetwork SSLHandshake失败(-9806)错误

时间:2013-11-27 14:16:30

标签: ios objective-c

我正在尝试使用

调用我的网址
NSDictionary *landingDetails=[appDelegate landingPage];

        NSString *devinf=[UIDevice currentDevice].systemVersion;
        NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];

        NSMutableDictionary *reqDict=[NSMutableDictionary dictionary];
        [reqDict setObject:@"refillByScan" forKey:@"appId"];
        [reqDict setObject:@"extest1" forKey:@"affId"];
        [reqDict setObject:[landingDetails objectForKey:@"token"] forKey:@"token"];
        [reqDict setObject:@"0124400-59382" forKey:@"rxNo"];//medication or prescription id
        [reqDict setObject:@"appName://handleControlFromScanRefill" forKey:@"appCallBackScheme"];
        [reqDict setObject:@"callBackAction" forKey:@"appCallBackAction"];
        [reqDict setObject:@"chkExpRx" forKey:@"act"];
        [reqDict setObject:@"" forKey:@"trackingId"];
        [reqDict setObject:devinf forKey:@"devinf"];
        [reqDict setObject:appVersion forKey:@"appver"];

        NSString *landingUrl=[landingDetails objectForKey:@"landingUrl"];//my url
        request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:landingUrl]];
        NSString *jsonRequest = [reqDict JSONRepresentation];
        NSLog(@"jsonRequest is %@", jsonRequest);
        NSData *requestData = [NSData dataWithBytes:[jsonRequest UTF8String] length:[jsonRequest length]];

        [request setHTTPMethod:@"POST"];
        [request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
        [request setHTTPBody: requestData];

        con=[[NSURLConnection alloc]initWithRequest:request delegate:self];
        [con start];

我在日志中收到此错误

2013-11-27 19:43:30.754 WallGreen[5594:3a03] CFNetwork SSLHandshake failed (-9806)
2013-11-27 19:43:31.273 WallGreen[5594:3a03] CFNetwork SSLHandshake failed (-9806)
2013-11-27 19:43:31.799 WallGreen[5594:3a03] CFNetwork SSLHandshake failed (-9806)
2013-11-27 19:43:31.800 WallGreen[5594:3a03] NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)

3 个答案:

答案 0 :(得分:5)

FWIW:我得到了相同的错误号,这是由于证书过期,所以这是该问题的另一个潜在来源。

答案 1 :(得分:1)

使用具有哈希函数SHA512的证书时,iOS 8上存在错误,最好使用SHA256。我坚持这个错误好几个星期。

答案 2 :(得分:1)

通常当我收到CFNetwork SSLHandshake失败时 - (*)因为我的本地wifi网络(设备连接到网络而不是互联网)

在另一个网络上再试一次(3G对我来说是最快的解决方案)