xcode iOS NSURLConnection/CFURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9813)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26874219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:09:37  来源:igfitidea点击:

iOS NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)

iosxcodesslnsurlconnectionnsurlrequest

提问by Mike Simz

I am getting this error whenever I try making a request to our server. It was working fine before we setup SSL, not it is all messed up..here is my code:

每当我尝试向我们的服务器发出请求时,都会收到此错误。在我们设置 SSL 之前它运行良好,不是全部搞砸了..这是我的代码:

  // Setup URL POST Request..
NSString* code4ArmourUrl = [NSString stringWithFormat:@"https://api.code4armour.com/index.php/user/login?"];

NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:code4ArmourUrl ]];
[request setHTTPMethod:@"POST"];
[request addValue:@"00000000000000000000000000000000" forHTTPHeaderField:@"X-api-key"];

NSString* postString = [NSString stringWithFormat:@"email=%@&password=%@",emailString,passwordString];
postString = [postString stringByReplacingOccurrencesOfString:@"+" withString:@"%2b"];

[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];


// Make URL POST Request..
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError* connectionError) {

Any reason why this isn't working..I believe it is an issue with SSL but I don't know how to get around this without doing something hacky that Apple won't end up accepting on to the App Store?

这不工作的任何原因..我相信这是 SSL 的问题,但我不知道如何解决这个问题而不做一些苹果最终不会接受 App Store 的黑客行为?

Any help would be greatly appreciated! Thanks.

任何帮助将不胜感激!谢谢。

回答by Steffen Ullrich

Your server is not set up correctly. While it probably has a properly signed certificate it is missing the chain certificates leading to the trusted root. See the problems reported by SSLLabs analysisabout additional certificates and the certification path.

您的服务器设置不正确。虽然它可能有一个正确签名的证书,但它缺少通向受信任根的链证书。参见SSLLabs 分析报告的关于附加证书和认证路径的问题。

How to configure these missing intermediate certificates depends on your server. For more information see Godaddy support site.

如何配置这些缺少的中间证书取决于您的服务器。有关更多信息,请参阅Godaddy 支持站点