sendSynchronousRequest with self signed certificate

Hi


Due to the application design I cannot use the – initWithRequest:delegate: method of NSURLConnection class for my https requests to a server. Hence I have to make synchronous calls using sendSynchronousRequest:returningResponse:error.


When I was using initWithRequest , it was taking a class delegate of NSURLConnectionDelegate class hence I handled the self signed certificate problem by the following code:-


- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {


return [protectionSpace.authenticationMethodisEqualToString:NSURLAuthenticationMethodServerTrust];

}


- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {

[challenge.senderuseCredential:[NSURLCredentialcredentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];

[challenge.sendercontinueWithoutCredentialForAuthenticationChallenge:challenge];

}



Now the problem is that sendSynchronousRequest does not take any delegates to be called on. So now how do I handle non trusted certificate problem using synchronous request.



I searched but so far can't find any solution.

iPad 2, iOS 6.0.2

Posted on Jan 30, 2013 6:42 PM

Reply

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

sendSynchronousRequest with self signed certificate

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.