Note that there are some explanatory texts on larger screens.

plurals
  1. PONSURLErrorDomain Code=-1202 when using Syncronous request
    primarykey
    data
    text
    <p>I try to send the synchronous request and got the below error.</p> <blockquote> <p>Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “xx.xxxx.com” which could put your confidential information at risk."</p> </blockquote> <p>Please find the code below</p> <pre><code> NSURL *url=[[NSURL alloc]initWithString:strURL]; NSMutableURLRequest *request=[[NSMutableURLRequest alloc]initWithURL:url]; [url release]; [request setTimeoutInterval:90]; [request setHTTPMethod:@"POST"]; [request setHTTPBody:dataForChallenge]; [request setValue:@"application/json" forHTTPHeaderField:@"content-type"]; [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; NSURLResponse *resp = nil; NSError *err = nil; NSData *response = [NSURLConnection sendSynchronousRequest: request returningResponse: &amp;resp error: &amp;err]; - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { // NSLog(@"selector : %@",NSStringFromSelector(_cmd)); if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { // NSLog(@"selector 1: %@",NSStringFromSelector(_cmd)); [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; } [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge]; } - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { // NSLog(@"selector : %@",NSStringFromSelector(_cmd)); if( [[protectionSpace authenticationMethod] isEqualToString:NSURLAuthenticationMethodServerTrust] ) { // NSLog(@"selector 1: %@",NSStringFromSelector(_cmd)); return YES; } return NO; } </code></pre> <p>The above two methods are not getting called, in my case i have to send Synchronous request only. </p> <p>I used the below line and it works fine but AppStore rejected my App:</p> <pre><code> [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]]; </code></pre> <p>How can i fix this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload