如何使用WKWebView正确实现身份验证质询?

时间:2017-03-08 12:25:38

标签: ios objective-c wkwebview

我正在构建一个Web浏览器,在网络方面我真的很新手。

我想测试下面的代码示例,但我没有真实的例子可以使用:

- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler
{
    CFDataRef exceptions = SecTrustCopyExceptions(challenge.protectionSpace.serverTrust);

    SecTrustSetExceptions(challenge.protectionSpace.serverTrust, exceptions);

    CFRelease(exceptions);

    completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
}

任何人都可以提供我可以测试上述代码的网址吗?

编辑:我开始赏金,因为我感到筋疲力尽。我正在完成我创建的应用程序,每天都会出现很多问题。我真的很感激你的帮助!

1 个答案:

答案 0 :(得分:-1)

@Vulkan请使用此链接查看您的代码。

http://samvermette.com

我使用了https://github.com/TransitApp/SVWebViewController

中的这个链接