views:

240

answers:

0

Ho all! I'm trying to' make a login with the iPhone into a https server.. I tried different solution, also asihttprequest and the solution works fine with http normal website, but with https the return data is the same of the login page... I news to' make something different for https? Thanks in advance

this is the code that I tried: one with asihttprequest

ASIFormDataRequest  *request = [[[ASIFormDataRequest  alloc]  initWithURL:[NSURL URLWithString:@"https://members.website.com/login.jsp"]] autorelease];
[request setRequestMethod:@"POST"];
[request setPostValue:@"myUser" forKey:@"username"];
[request setPostValue:@"myPass" forKey:@"password"];
[request setPostValue:@"-600" forKey:@"utcoffset"];
[request setPostValue:@"" forKey:@"todaysdate"];
[request setValidatesSecureCertificate:NO];
[request startSynchronous];
NSError *error = [request error];
if (!error) {
 NSString *response = [request responseString];
 //txResult    .text = response;
 [txResult loadHTMLString:response baseURL:[NSURL URLWithString:@"https://members.website.com/login.jsp"]];
}

and one with the NSMutableURLRequest

NSString *urlString = [NSString stringWithFormat:@"https://members.website.com/login.jsp"];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
[request setValue:@"myUser" forHTTPHeaderField:@"username"];
[request setValue:@"myPass" forHTTPHeaderField:@"password"];
[request setValue:@"-600" forHTTPHeaderField:@"utcoffset"];
[request setValue:@"" forHTTPHeaderField:@"todaysdate"];
NSHTTPURLResponse* urlResponse = nil;  
NSError *error = [[NSError alloc] init];  
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];  
NSString *result = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"Response Code: %d", [urlResponse statusCode]);
if ([urlResponse statusCode] >= 200 && [urlResponse statusCode] < 300) {
 NSLog(@"Response: %@", result);

 //here you get the response
 [txResult loadHTMLString:result baseURL:[NSURL URLWithSt

ring:@"https://members.website.com/login.jsp"]]; }