CFNetwork SSLHandshake failed (-9806)

Hi Support


I am getting this error in my APP.......


2016-01-28 12:57:51.900 Safe Text[360:113893] CFNetwork SSLHandshake failed (-9806)
2016-01-28 12:57:51.902 Safe Text[360:113893] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
2016-01-28 12:57:51.906 Safe Text[360:113869] Connection Error Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9806, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x126dcf630 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSErrorFailingURLStringKey=https://client.safe-text.com/api/sync/, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFNetworkCFStreamSSLErrorOriginalValue=-9806, _kCFStreamPropertySSLClientCertificateState=0, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., _kCFStreamErrorDomainKey=3, NSErrorFailingURLKey=https://client.safe-text.com/api/sync/, _kCFStreamErrorCodeKey=-9806}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://client.safe-text.com/api/sync/, NSErrorFailingURLStringKey=https://client.safe-text.com/api/sync/, _kCFStreamErrorDomainKey=3}


I tried to connect with my server support related to SSL and they provided me detail related to SSL.You can check SSL detail from this link http://giftsoninternet.com/Screenshot.jpg. I am not getting is there something wrong in my APP code or something not setup properly related to SSL on server.


Can you please check this error and attached SSL detail..........please help me to figure out this issue.


Thanks

It’s hard to say what’s going on here without more context. If I create a simple test app that accesses

https://client.safe-text.com/api/sync/
, the TLS side of things works just fine (the request completes with no error, with an HTTP status of 200, and an HTTP body that says
GET requests are not supported for sync
). So this TLS-level error is either environmental (it happens in your environment but not in mine) or related to the specific request you sent.

To tease these apart I recommend you create a small test app that does the following:

[[[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:@"https://client.safe-text.com/api/sync/"] completionHandler:^(NSData * data, NSURLResponse * response, NSError * error) {
    #pragma unused(response)
    if (error == nil) {
        NSLog(@"task finished with status %d", (int) ((NSHTTPURLResponse *) response).statusCode);
    } else {
        NSLog(@"task error %@ / %d", error.domain, (int) error.code);
    }
    NSLog(@"task data %@", data);
}] resume];

I ran this app and it produced results like this:

task start
task finished with status 200
task data <7b227374 61747573 223a2266 61696c22 2c226461 7461223a 7b226d65 73736167 65223a22 47455420 72657175 65737473 20617265 206e6f74 20737570 706f7274 65642066 6f722073 796e6322 7d7d>

If you run the same code at your end, what do you see?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi eskimo


Thanks for the quick reply........


Let me tell you more in detail. My APP name is safetext. Also we have android version for this APP. There is no such type of issue with Andorid users. We are getting this issue from IOS users only.


Also let me tell you for iOS users its not stable. They are getting this issue normally when the app is in background for long time.


So sometime APP is not able to create secure connection with server. At that time APP stop working....but after sometime when APP able to make secure connection with server then it starts working again.


So when we tried to find this case then found this error ..."CFNetwork SSLHandshake failed (-9806)". So I am not getting why APP is not able to make secure connection with server SOMETIME.


Please let me know if you need more info from my side ..........to clear about this issue.


Also let me tell you we are using NSURLConnection and its delegates.


Thanks

Also let me tell you we are using NSURLConnection and its delegates.

This doesn’t make a difference with regards TLS negotiation; NSURLSession and NSURLConnection use the same core code for that.

They are getting this issue normally when the app is in background for long time.

OK. Given that things normally work I very much doubt this is related to TLS negotiation. That tends to either work or not work in a very digital fashion.

You should enable CFNetwork diagnostic logging and see what that shows you. See QA1887 CFNetwork Diagnostic Logging for details.

Oh, and btw, have you tried this in different network environments? I’m specifically interested in seeing if it reproduces with multiple different WWAN carriers. I’ve seen something similar to this in the past that turned out to be carrier dependent.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
CFNetwork SSLHandshake failed (-9806)
 
 
Q