Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in GET on https ?? Can't set NSLocalizedRecoverySuggestion

    NSURL *url = [NSURL URLWithString:@"https://myUrlString.com"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url]; 

    NSURLResponse *responseurl;
    NSError *err;
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&responseurl error:&err]; 
    NSLog(@"data length:%u", data.length);
    NSLog(@"response:%@ , error:%@", responseurl, err);

And the response i got is :-

data length:0
response:(null) , 

error:Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “myUrlString.com” which could put your confidential information at risk." UserInfo=0x8742d70 {NSErrorFailingURLStringKey=https:https://myUrlString.com,

NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?,

NSErrorFailingURLKey=https://myUrlString.com,

NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “myUrlString.com” which could put your confidential information at risk., NSUnderlyingError=0x8745bf0 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “myUrlString.com” which could put your confidential information at risk.", NSURLErrorFailingURLPeerTrustErrorKey=}

like image 555
Zubair Avatar asked Mar 08 '26 00:03

Zubair


1 Answers

You are using Https request so you should use ASIHTTPRequest or you may try this code

NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];

[request setURL:[NSURL URLWithString:@"https:yoururl"]];
[request setHTTPMethod:@"GET"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:getData];
like image 105
Mashhadi Avatar answered Mar 10 '26 12:03

Mashhadi