Added return status checks when handling connection's authentication challenge
This commit is contained in:
parent
02abb706d3
commit
b60848af94
1 changed files with 15 additions and 13 deletions
|
|
@ -627,15 +627,17 @@ willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challe
|
|||
|
||||
OSStatus status = SecTrustCreateWithCertificates(certificates, policy, &trust);
|
||||
NSAssert(status == errSecSuccess, @"SecTrustCreateWithCertificates error: %ld", (long int)status);
|
||||
|
||||
if (status == errSecSuccess && trust) {
|
||||
SecTrustResultType result;
|
||||
status = SecTrustEvaluate(trust, &result);
|
||||
NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status);
|
||||
|
||||
if (status == errSecSuccess) {
|
||||
[trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)];
|
||||
}
|
||||
}
|
||||
|
||||
CFRelease(trust);
|
||||
CFRelease(certificates);
|
||||
if (trust) CFRelease(trust);
|
||||
if (certificates) CFRelease(certificates);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -679,7 +681,7 @@ willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challe
|
|||
OSStatus status = SecTrustEvaluate(serverTrust, &result);
|
||||
NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status);
|
||||
|
||||
if (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed) {
|
||||
if (status == errSecSuccess && (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed)) {
|
||||
NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust];
|
||||
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue