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>