Showing posts with label certificate. Show all posts
Showing posts with label certificate. Show all posts

Monday, November 15, 2010

Everything That Can Go Wrong With Xcode Build and Release

Right now I'm in the middle of serious mess up of my Xcode development environment, can't create ad hoc builds. No idea what triggered it, thus no idea what or how to fix. Since same error notes keep popping up time after time, I start documenting each. Maybe I'll slowly gather enough info to fix something.

Xcode error notes:
Useful articles:
Useful sites:
Have patience, try again, just keep bumbing your head into wall, no pain no gain, good luck, it works for me, wave the rubber chicken above monitor... yep, I know: none of it helps.

You have sympathy. It won't help either.

Build & Archive - Share Application - CSSMERR_TP_NOT_TRUSTED

Build & Archive - Share Application and both Email and Save fail without any visible error note. You seem to have been simply ignored. Try again to be totally ignored.

Possible error notes you can find from Console application - Databases searches - Console Messages:
  •     Command /usr/bin/codesign failed with exit code 1
  •     CSSMERR_TP_NOT_TRUSTED
Open Keychain Access, go to "login" keychain "Certificates" catogory. Open each development related certificate (Apple WorldWide Developer Relations Certification Authority, iPhone Developer, iPhone Distribution) and make sure their Trust details are "Use System Defaults"

Thursday, July 15, 2010

How to Accept Self-Signed Server Certificate

We have public server, test server and release test server. Likewise I generate three different binaries, each connecting to different server. The problem is that test servers have self-signed certificates and iPhone fails by default in NSURLConnection sendSynchronousRequest. The error note is:

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:
#if (defined(TEST_VERSION) || defined(RELEASE_TEST_VERSION))
    [NSURLRequest setAllowsAnyHTTPSCertificate:YES
                                       forHost:[url host]];
#endif
    [NSURLConnection sendSynchronousRequest:request 
                          returningResponse:&response
                                      error:&error];
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.

To remove compiler warning add this at the beginning of your file:
#if (defined(TEST_VERSION) || defined(RELEASE_TEST_VERSION))
@interface NSURLRequest (DummyInterface)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString*)host;
+ (void)setAllowsAnyHTTPSCertificate:(BOOL)allow forHost:(NSString*)host;
@end
#endif
More info at Dr. Touch article: Ignoring Certificate Errors on NSUrlRequest.

iOS5 update: this code might (or maybe not) help a little from my blog article Server API change from HTTP to HTTPS