gpt4 book ai didi

iphone - 从 NSUrlConnection didReceiveAuthenticationChallenge 提供有意义的错误

转载 作者:可可西里 更新时间:2023-11-01 04:59:28 25 4
gpt4 key购买 nike

我正在使用 Certificate and Public Key Pinning 的 OWASP 示例.该示例使用 random.org , 和 random.org最近拿到了新证书。这意味着 connection:didReceiveAuthenticationChallenge: 失败了。这是意料之中的好事:)

但是,失败显示为“NSURLErrorDomain”,代码为 -1012。这不是很有帮助,用户将无法用它做任何有意义的事情:

enter image description here

最好提供一条消息,其中包含类似于“警告:标识网站的公钥已更改...”的文本。

另一个小问题:在 connection:didFailWithError: 中,我无法判断 -1012 是由于固定失败还是其他网络错误造成的。所以我只想提供证书失败的消息,而不是其他 -1012 错误。

如何向 [[challenge sender] cancelAuthenticationChallenge: challenge] 的调用提供“丰富的错误信息”(当 connection:didReceiveAuthenticationChallenge: 失败时调用) . NSURLConnectionDelegate Protocol ReferenceNSURLAuthenticationChallengeSender Protocol Reference不要提及如何做到这一点。

最佳答案

尝试使用

NSString * alertMessage = [challenge.error localizedFailureReason];

获取人类可读的错误信息。

请参阅 NSError 的文档和 NSURLAuthenticationChallenge .

关于iphone - 从 NSUrlConnection didReceiveAuthenticationChallenge 提供有意义的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15077945/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com