didreceiveresponse never called in HTTP post request … NSURLSession/NSURLConnection HTTP load failed

I have a very simple code to post an XML data on amazon web service. Unfortunately, the data is never posted on the website I cant seem to figure out the problem. I get the following error: NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)

I have modified the info.plist to add domain exceptions but it doesnt seem to fix my problem. I have read all possible threads on this issue and it hasnt helped me so far. I would really appreciate if community experts could shed some light on this issue.


After modifying the info.plist, the "CFNetwork SSLHandshake failed" error no longer shows up but the "NSURLSession/NSURLConnection HTTP load failed" still persists. Does any one have any clue of what might be going on here. Thanks again.


NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://ec2-54-85-5-148.compute-1.amazonaws.com:8443/addResult"]];
request.HTTPMethod = @"POST"; 
[request setValue:@"xml" forHTTPHeaderField:@"Content-Type"]; 
NSString *authStr = [NSString stringWithFormat:@"%@:%@", @"username", @"password"]; 
NSData *authData = [authStr dataUsingEncoding:NSUTF8StringEncoding]; 
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64Encoding]]; 
[request setValue:authValue forHTTPHeaderField:@"Authorization"]; 
NSString *stringData = @"<data><DateTime>2015-12-9T00:00-08:00</DateTime><SourceID>Site200</SourceID><Result>1</Result>"; 
NSData *requestBodyData = [stringData dataUsingEncoding:NSUTF8StringEncoding]; 
request.HTTPBody = requestBodyData; / 
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; 
[connection start]; 
if(connection){ NSLog(@"Connection complete"); } 
else{ NSLog(@"Connection could not be made"); }


The modified info.plist contains the exception domain snippet:

<key>NSAppTransportSecurity</key> 
<dict> 
<key>NSExceptionDomains</key> 
<dict> 
<key>ec2-54-85-5-148.compute-1.amazonaws.com</key> 
<dict> 
<key>NSThirdPartyExceptionMinimumTLSVersion</key> 
<string>TLSv1.2</string> 
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key> 
<false/> 
<key>NSIncludesSubdomains</key> 
<true/> 
</dict> 
<key>ec2-54-85-5-148.compute-1.amazonaws.com</key> 
<dict> 
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
 <string>TLSv1.2</string> 
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key> 
<false/> 
<key>NSIncludesSubdomains</key>
 <true/> 
</dict> 
</dict> 
</dict>

I suggest you start by disabling ATS completely. Put the following in your

Info.plist
and see what happens.
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

If that works then you know you have an ATS issue and you can investigate from there. OTOH, if that doesn’t work then you know that you have problems beyond ATS.

ps I tried to connect to your server but it’s not responding:

$ telnet ec2-54-85-5-148.compute-1.amazonaws.com 443
Trying 54.85.5.148...
telnet: connect to address 54.85.5.148: Operation timed out
telnet: Unable to connect to remote host

If you confirm that this is an ATS issue, it’d be helpful if you could post the result of the following command:

$ TLSTool s_client -connect ec2-54-85-5-148.compute-1.amazonaws.com:443

where

TLSTool
is a build of the TLSTool sample code.

Share and Enjoy

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

let myEmail = "eskimo" + "1" + "@apple.com"
didreceiveresponse never called in HTTP post request … NSURLSession/NSURLConnection HTTP load failed
 
 
Q