【发布时间】:2014-11-11 20:45:20
【问题描述】:
每当我尝试向我们的服务器发出请求时,我都会收到此错误。在我们设置 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) {
这不起作用的任何原因..我相信这是 SSL 的一个问题,但我不知道如何解决这个问题而不做一些苹果最终不会接受 App Store 的黑客行为?
任何帮助将不胜感激!谢谢。
【问题讨论】:
-
您是否能够在 Mac 上使用 cURL 成功发送请求?你确定服务器工作正常吗?您是否缺少定义身份验证数据的标头?
-
在我的 Mac 上使用 cURL 没有问题。这里发生了奇怪的事情!帮助!
-
看起来在 cURL 中它没有验证证书..这是我的问题吗?如果是这样,我该如何解决这个问题?
标签: ios xcode ssl nsurlconnection nsurlrequest