views:

334

answers:

0

In the initWithIdentity:certificates:persistence: method, what is the purpose of the certificates argument? The identity has a certificate associated with it, so which other certificates am I expected to pass to this call?

The server is not accepting my certificate, and I suspect it is because I'm calling this wrong.

This is my callback code:

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
NSURLCredential *credential = nil;
SecIdentityRef identity = [self identityWithCommonName:@"<common name here>"];
SecCertificateRef certRef = nil;

SecIdentityCopyCertificate(identity, &certRef);
credential = [NSURLCredential credentialWithIdentity:identity
                                        certificates:[NSArray arrayWithObject:(NSObject *)certRef]
                                         persistence:NSURLCredentialPersistenceForSession];
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];

}