我使用以下代码来验证用户使用远程服务器的认证。 如果我给出正确的用户名和密码, 没有问题, 因为认证正在发生, 我正从服务器收到回复 。
但当我给错误的证明书时, 这种方法被反复使用, 所以我无法打破它。
请帮助我,如何打破它 这样我就可以显示 认证失败的警告信息。
- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"username"
password:@"password"
persistence:NSURLCredentialPersistenceForSession];
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
}