如何使用WKWebView正确实现身份验证质询? [英] How can I properly implement an authentication challenge using a WKWebView?

查看:188
本文介绍了如何使用WKWebView正确实现身份验证质询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm building a web browser and I'm really novice when it comes to networking.

我想测试下面的代码示例但是我有没有现实生活中的例子:

I'd like to test the code sample bellow but I have no real life example to work with:

- (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]);
}

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

Can anyone provide a URL where I can test the code above?

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

I started a bounty because I feel exhausted. I'm in the process of finalizing the application I created and there are so many issues popping up everyday. I'd really appreciate a helping hand!

推荐答案

@Vulkan请点击此链接查看您的代码。

@Vulkan Please check your code with this link.

http://samvermette.com

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

这篇关于如何使用WKWebView正确实现身份验证质询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆