双向SSL在WatchOS2.1上失败,但在iOS9.1上使用相同的代码
我试图与具有双向SSL的服务通信 我通过调用双向SSL在WatchOS2.1上失败,但在iOS9.1上使用相同的代码,ssl,ssl-certificate,watchos-2,ios9.1,Ssl,Ssl Certificate,Watchos 2,Ios9.1,我试图与具有双向SSL的服务通信 我通过调用completeHandler(NSURLSessionAuthChallengeUseCredential,credential)发现,在客户端(监视)提供客户端证书后,连接立即被取消。 得到的错误是: NSURErrorDomain代码=-999已取消 但是我试着在手机上运行同样的代码,它成功了。 除此之外,其他请求在手表上也可以正常工作 由于WatchOS和iOS上的框架不同,我想知道这是否是WatchOS的一个问题?或者,手表是否需要特别配置
completeHandler(NSURLSessionAuthChallengeUseCredential,credential)发现,在客户端(监视)提供客户端证书后,连接立即被取消。
得到的错误是:
NSURErrorDomain代码=-999已取消
但是我试着在手机上运行同样的代码,它成功了。
除此之外,其他请求在手表上也可以正常工作
由于WatchOS和iOS上的框架不同,我想知道这是否是WatchOS的一个问题?或者,手表是否需要特别配置
这是密码
- (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);
}
}
由苹果工程师确认。
这是对Watch OS的限制。目前不支持双向SSL。您可以显示更多代码吗?在watchOS 5 beta 1中仍然没有修复。