Skip to content

Instantly share code, notes, and snippets.

@adamkaplan
Last active June 23, 2017 20:40
Show Gist options
  • Save adamkaplan/f06775be49472747e448416230115a0f to your computer and use it in GitHub Desktop.
Save adamkaplan/f06775be49472747e448416230115a0f to your computer and use it in GitHub Desktop.
trustkit-discuss
- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition,
NSURLCredential *credential))completionHandler
{
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
{
[TSKPinningValidator handleChallenge:challenge completionHandler:completionHandler];
}
else
{
// This challenge was not for server trust. Fall back to default behavior.
NSAssert(@"Unsupported authentication method");
completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
}
}
- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition,
NSURLCredential *credential))completionHandler
{
if (![TSKPinningValidator handleChallenge:challenge completionHandler:completionHandler])
{
// TrustKit did not handle this challenge: perhaps it was not for server trust
// or the domain was not pinned. Fall back to the default behavior
completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment