NSURLAuthenticationMethodServerTrust seems broken in iOS11

I have some code to perform https request using NSURLSession in objective-C


In - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler

my app loads the server certificate and checks the remote.


It works fine with iOS 9 and iOS10.


(code is similar as posted by eskimo1 in swift: https://forums.developer.apple.com/message/229390#229390)

However in iOS 11, after calling:

NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];

completionHandler(NSURLSessionAuthChallengeUseCredential,credential);


the app crash inside CFNetwork.connection


I filed a radar rdar://32950319


Has someone obeserved the same issue ?

Replies

same for me

Same for me 😮

same for me (

iOS 11 only. We have fixed our issue by changing:
// Establish a chain of trust anchored on our bundled certificate.
CFArrayRef certArrayRef = CFArrayCreate(NULL, (void *)&cert, 1, NULL);

to

CFArrayRef certArrayRef = CFArrayCreate(NULL, (void *)&cert, 1, &kCFTypeArrayCallBacks);