Steven Steven - 28 days ago 9
Objective-C Question

there is an issue with NSURLAuthenticationMethodClientCertificate that no return

I am using mutual authentication in iOS 10 that with if statement bellow mutual authentication works correctly.

-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
if ([protectionSpace authenticationMethod] == NSURLAuthenticationMethodServerTrust) {

// do something

} else if ([protectionSpace authenticationMethod] == NSURLAuthenticationMethodClientCertificate) {

// Do something

}
}


In iOS 10 the response return with

NSURLProtectionSpace* protectionSpace = challenge.protectionSpace;

NSURLAuthenticationMethodClientCertificate


And the problem is in iOS 11 the response return:

NSURLAuthenticationMethodServerTrust


How to force it that response return NSURLAuthenticationMethodClientCertificate the first tome instead of NSURLAuthenticationMethodServerTrust.

Appreciate any help :)

Answer Source

I am going to answer it here after some hours research. In iOS 11 NSURLAuthenticationMethodServerTrust always arrive first then pass to NSURLAuthenticationMethodClientCertificate but in iOS 10 it work in opposite.