Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting CFNetwork SSLHandshake failed (-9806) error

I am trying to call my url using

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];

I am getting this error in my log

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)
like image 944
Jay Gajjar Avatar asked Nov 27 '13 14:11

Jay Gajjar


3 Answers

FWIW: I got the same error number and it was due to an expired certificate, so this is another potential source for the issue.

like image 97
Arkaaito Avatar answered Nov 04 '22 07:11

Arkaaito


There is a bug on iOS 8 when using a certificate with hash function SHA512, better use the SHA256. I stuck with this error for weeks.

like image 35
sarge Avatar answered Nov 04 '22 09:11

sarge


Normally when I get CFNetwork SSLHandshake failed -(*) Its because of my local wifi network (device is connected to network but not the internet)

Try it again on another network (3G is the quickest solution for me)

like image 1
Usman Javed Avatar answered Nov 04 '22 07:11

Usman Javed