Reputation: 18922
I'm trying to debug an app that makes a lot of HTTP calls. I'm seeing this in the console:
2015-09-08 17:21:01.458 MyApp[3186:3064431] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
I understand how to add exceptions to my plist, but is there way to add a breakpoint where these requests are failing to see what is being requested?
Upvotes: 6
Views: 1293
Reputation: 196
While working with iOS 9, We have to put below lines in info.plist otherwise no any API call will work.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>dev.YourCompanyName.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<false/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<true/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSRequiresCertificateTransparency</key>
<false/>
</dict>
</dict>
</dict>
Upvotes: -1
Reputation: 258
I wasn't able to make much of the stack trace when adding those breakpoints; however, this blog post helped me figure out which domains were failing:
http://timekl.com/blog/2015/08/21/shipping-an-app-with-app-transport-security/
tl;dr: set the environment variable CFNETWORK_DIAGNOSTICS to 1 (how to set environment variables, if you need a hand: http://nshipster.com/launch-arguments-and-environment-variables/). this will log all the CFNetwork activity to a file that you'll see in the console; search that file for 'Did Fail' and you can see which requests are failing and why.
Upvotes: 6
Reputation: 1305
Try adding a symbolic breakpoint in HTTPProtocol::failWithStreamError
and/or StrictSecurityPolicy::logInsecureLoadFailure
.
(This unfortunately may not make it easy to get the stack trace of the actual request, since this exception occurs asynchronously with the actual request creation code. But it might help you anyway.)
Upvotes: 3