4
votes

I'm getting the infamous NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802) error on iOS 9. I don't want to add a global exception but for specific domains.

How do I know which URL causes this error?

2

2 Answers

4
votes

When your NSURLConnection or NSURLSessionTask error handling delegate method is called, obtain the URL from the request object and print it with NSLog (or just put a debug breakpoint in that method).

Or set the CFNETWORK_DIAGNOSTICS environment variable to 1 (or 2 or 3) if your code isn't making the request directly (e.g. if a third-party library is doing it on your behalf).

4
votes

You can set CFNETWORK_DIAGNOSTICS environment variable as @dgatwood suggested or you can call setenv("CFNETWORK_DIAGNOSTICS", "3", 1);, for example, in main.m file. Once you have done any of options you should see appropriate message in console log:

2014-10-28 14:23:37.115 QTestbed[2626:60b] CFNetwork diagnostics log file created at: /private/var/mobile/Applications/76531F40-3291-4565-8C75-0438052C83BC/Library/Logs/CrashReporter/CFNetwork_com.example.apple-samplecode.QTestbed_2626.nwlrb.log

Just open this file after some time of usage of your app and check logs there.

Here is a link to the related Apple's Q&A.