Merge pull request #2 from github/dont-cancel-authentication-requests

Don’t cancel authentication requests
This commit is contained in:
Josh Vera 2014-10-06 18:25:14 -04:00
Родитель 4b79bd91ed c875696814
Коммит d7bcfb85e8
1 изменённых файлов: 27 добавлений и 33 удалений

Просмотреть файл

@ -646,35 +646,29 @@ willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challe
break;
}
case AFSSLPinningModeNone: {
if (self.allowsInvalidSSLCertificate){
NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust];
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
} else {
SecTrustResultType result = 0;
OSStatus status = SecTrustEvaluate(serverTrust, &result);
NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status);
if (status == errSecSuccess && (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed)) {
if (self.allowsInvalidSSLCertificate || (status == errSecSuccess && (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed))) {
NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust];
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
return;
}
if ([[challenge sender] respondsToSelector:@selector(performDefaultHandlingForAuthenticationChallenge:)]) {
[[challenge sender] performDefaultHandlingForAuthenticationChallenge:challenge];
} else {
[[challenge sender] cancelAuthenticationChallenge:challenge];
}
[[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge];
}
break;
}
}
} else {
if ([challenge previousFailureCount] == 0) {
if (self.credential) {
} else if ([challenge previousFailureCount] == 0 && self.credential != nil) {
[[challenge sender] useCredential:self.credential forAuthenticationChallenge:challenge];
} else {
[[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge];
}
} else {
[[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge];
}
}
}
- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection {