NSURLConnection willSendRequestForAuthenticationChallenge persistence

时间:2015-10-31 00:04:47

标签: ios ssl tls1.2

The (soon to be deprecated) NSURLConnectionDelegate allows you to handle a TLS trust challenge like so: -(void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge(NSURLAuthenticationChallenge *)challenge { if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) [challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge]; } Assuming that the same x509 certificate is being presented by the same server, my testing shows that the effect of this method is cached for the duration of the application execution. This method is not hit again. Is there a way to force the application to forget the effect of this method after the handling has occurred, such that subsequent hits to the same web service force this method to be called?

1 个答案:

答案 0 :(得分:0)

我想我正在使用[challenge.sender cancelAuthenticationChallenge:...]。