首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >NSURLSession间歇SSLHandshake失败(-9810)错误

NSURLSession间歇SSLHandshake失败(-9810)错误
EN

Stack Overflow用户
提问于 2014-01-06 16:30:45
回答 1查看 2K关注 0票数 6

从安全URL下载图像,在安全墙后面。像https://foo.com/bar.png这样的URL

有时我会得到一个SSLHandshake错误。有时错误只发生一次,但有时错误是常量的,我无法下载该文件。

代码语言:javascript
运行
复制
DownloadImageApp[2914] <Warning>: CHALLENGE!!! (NSURLAuthenticationMethodServerTrust)
DownloadImageApp[2914] <Warning>:    server = foo.com
DownloadImageApp[2914] <Warning>: CFNetwork SSLHandshake failed (-9810)
DownloadImageApp[2914] <Warning>: CHALLENGE!!! (NSURLAuthenticationMethodServerTrust)
DownloadImageApp[2914] <Warning>:    server = foo.com
DownloadImageApp[2914] <Warning>: CHALLENGE!!! (NSURLAuthenticationMethodNTLM)
DownloadImageApp[2914] <Warning>:    NSURLAuthenticationMethodNTLM

我使用了以下代码来处理挑战

代码语言:javascript
运行
复制
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler {
    NSLog(@"CHALLENGE!!! (%@)", challenge.protectionSpace.authenticationMethod);

    if (challenge.error)
        NSLog(@"  -- error: %@", challenge.error.description);
    if (challenge.previousFailureCount > 0)
        NSLog(@"  -- previous failure count = %d", challenge.previousFailureCount);
    if (challenge.proposedCredential)
        NSLog(@"  -- proposed credential user: %@", challenge.proposedCredential.user);

    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
        NSLog(@"   server = %@", challenge.protectionSpace.host);
        completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
    } else if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodNTLM]) {
        NSLog(@"   NSURLAuthenticationMethodNTLM");
        NSURLCredential *credential = [NSURLCredential credentialWithUser:@"username" password:@"passwordIsSecretShhh" persistence:NSURLCredentialPersistenceForSession];
        completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
    } else {
        NSLog(@"   ????");
    }
}

即使它完全失败并且不会加载,我仍然可以弹到Safari,输入URL并加载它。因此,我正在寻找的想法,将导致这个问题,而不是坏的网络问题或不稳定的问题与主机的web服务器。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-13 18:14:11

我终于解决了这个问题。这和我的代码无关。

这些问题是导致趋势SSL监控软件安装在服务器上的原因。一旦软件被禁用,错误立即消失。

这不是一个很好的答案,但希望它能帮助到其他人。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20954560

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档