On 12 Jun '08, at 8:35 AM, Paul E. Robichaux wrote:

@implementation NSURLRequest(NSHTTPURLRequest)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
   return YES;
}
@end

At the end of one of my .m files, the code builds, though I get warnings that some other methods aren't implemented. The program then gives me an
NSURLDomainError -1203

I'm suspicious of that technique, since category methods really aren't allowed to override existing methods; I think the effects are "undefined". It's the kind of thing that I could imagine breaking under the rewritten Obj-C runtime in 10.5.

1. Is there a safer or better-supported way for me to get a look at the returned certificate besides overriding allowsAnyHTTPSCertificateForHost?

Well, this message from Marcel Borsten
        http://www.cocoabuilder.com/archive/message/cocoa/2008/3/4/200382
mentions another method:
        + (void)setAllowsAnyHTTPSCertificate:(BOOL)fp8 forHost:(id)fp12;

So it looks as though you could just call
        [NSURLConnection setAllowsAnyHTTPSCertificate: YES forHost: myHost];
You would just have to paste the @interface block (but NOT the @implementation) from that email into your code, so the compiler recognizes the existence of that method.

A better solution is to insert the cert into the keychain and mark it as trusted; but that isn't easy. If the user can get a ".cer" file of the server's cert, s/he can double-click it to add it to the keychain, then locate it in Keychain Access and mark it as trusted. Programmatically, it involves some twisty little APIs; I'd recommend using the higher-level wrappers in the open-source Keychain.framework (it's on sourceforge.)

3. What does -1203 really *mean*?

From NSURLError.h:
    NSURLErrorServerCertificateHasUnknownRoot = -1203,

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to