Skip to content

Commit

Permalink
Merge pull request #63 from 8W9aG/fix-https-2
Browse files Browse the repository at this point in the history
Delegate challenges to the default handling
  • Loading branch information
8W9aG committed Jan 30, 2016
2 parents cf10718 + 2b8052b commit cadbab4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion SPTDataLoader/SPTDataLoaderService.m
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ - (void)URLSession:(NSURLSession *)session
SecTrustRef trust = challenge.protectionSpace.serverTrust;
completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:trust]);
} else {
completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
}
}

Expand Down
16 changes: 16 additions & 0 deletions SPTDataLoaderTests/SPTDataLoaderServiceTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,20 @@ - (void)testCancellingLoads
[service cancelAllLoads];
}

- (void)testDidReceiveChallengeWhenNotAllowingAllCertificatesForwardsResponsiblity
{
NSURLSession *session = [NSURLSession new];
NSURLSessionTask *task = [NSURLSessionTask new];
NSURLAuthenticationChallenge *challenge = [NSURLAuthenticationChallenge new];
__block NSURLSessionAuthChallengeDisposition savedDisposition = NSURLSessionAuthChallengeUseCredential;
void(^NSURLSessionCompletionHandler)(NSURLSessionAuthChallengeDisposition, NSURLCredential *) = ^(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential) {
savedDisposition = disposition;
};
[self.service URLSession:session
task:task
didReceiveChallenge:challenge
completionHandler:NSURLSessionCompletionHandler];
XCTAssertEqual(savedDisposition, NSURLSessionAuthChallengePerformDefaultHandling);
}

@end

0 comments on commit cadbab4

Please sign in to comment.