首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >两种方式的SSL在WatchOS2.1上失败,但在iOS9.1上相同的代码工作

两种方式的SSL在WatchOS2.1上失败,但在iOS9.1上相同的代码工作
EN

Stack Overflow用户
提问于 2016-02-23 04:19:09
回答 1查看 186关注 0票数 2

我试图用双向SSL与服务进行通信。

我发现在客户端(手表)提供客户端证书后,通过调用completeHandler(NSURLSessionAuthChallengeUseCredential, credential)立即取消了连接。

得到的错误是:

NSURLErrorDomain代码=-999取消

但是我试过在手机上运行同样的代码,它成功了。除此之外,其他要求在手表上也能正常工作。

由于WatchOS和iOS上的框架是不同的,我想知道这是否是WatchOS的一个问题?或者有什么特别需要为手表配置的吗?

这是代码

代码语言:javascript
复制
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler
{
    NSURLProtectionSpace *protectionSpace = [challenge protectionSpace];
    NSString *authMethod = [protectionSpace authenticationMethod];
    if (authMethod == NSURLAuthenticationMethodServerTrust) {
        completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:serverTrust]);
    } else if (authMethod == NSURLAuthenticationMethodClientCertificate) {
        // cancelled immediately after calling the method below.
        completionHandler(NSURLSessionAuthChallengeUseCredential, self.credential);
    } else {
        completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
    }
}
EN

回答 1

Stack Overflow用户

发布于 2016-04-06 06:33:23

得到苹果工程师的确认。这是对Watch OS的限制。目前不支持双向SSL。

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

https://stackoverflow.com/questions/35568750

复制
相关文章

相似问题

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