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

Vul*_*kan 8 objective-c ios 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]);
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以提供我可以测试上面代码的URL吗?

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

小智 -1

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

http://samvermette.com

我使用了https://github.com/TransitApp/SVWebViewController中的此链接