IPhone Development: How to Implement HTTPS Connection?
4 answers
Ben Copsey ASIHTTPRequest
framework makes it easy to issue web requests over SSL.
Modify the example site a bit:
NSURL *url = [NSURL URLWithString:@"https://allseeing-i.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request startSynchronous];
NSError *error = [request error];
if (!error) {
NSString *response = [request responseString];
NSLog (@"%@", response);
}
+2
a source to share
Just use NSURLConnection with NSURLRequest pointing to NUSUL with https protocol, exactly the same:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://mySecureServer.net"]];
NSURLResponse *response = nil;
NSError *error = nil;
NSData *result = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if (!error) {
//do something with response & data
}
But I suggest you check out the documentation for the URL loading system in Cocoa.
0
a source to share
Jason don't forget to implement the connection: canAuthenticateAgainsProtectionSpace and the connection: didReceiveAuthenticationChallenge to make sure you handle the server authentication and client authentication issues:
Remember this post to help you with this https://devforums.apple.com/message/143091#143091
0
a source to share