ERROR CODE -1202 = The certificate for this server is invalid. You might be connecting to a server that is pretending to be “xx.xx.xxx.xxx” which could put your confidential information at risk.The solution with iOS4 is this one line:
Please note that the specific line is undocumented class method and thus not used in official release, only for testing with simulator or ad hoc releases.
#if (defined(TEST_VERSION) || defined(RELEASE_TEST_VERSION)) [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]]; #endif [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
To remove compiler warning add this at the beginning of your file:
More info at Dr. Touch article: Ignoring Certificate Errors on NSUrlRequest.
#if (defined(TEST_VERSION) || defined(RELEASE_TEST_VERSION)) @interface NSURLRequest (DummyInterface) + (BOOL)allowsAnyHTTPSCertificateForHost:(NSString*)host; + (void)setAllowsAnyHTTPSCertificate:(BOOL)allow forHost:(NSString*)host; @end #endif
iOS5 update: this code might (or maybe not) help a little from my blog article Server API change from HTTP to HTTPS