NSURLConnection无法发出HTTPS GET请求吗?

时间:2013-08-29 21:30:54

标签: ios ssl https request nsurlconnection

我正在做我正在为HTTP请求做的事情:

NSString *urlStrig = [NSString stringWithFormat:@"https://mysite.com/search.json?param1=10&param2=String&param3=20"];
NSURL *url = [NSURL URLWithString:urlStrig];
NSOperationQueue *queue = [NSOperationQueue new];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:Timeout];

[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {

    NSLog(@"URL:%@\nResponse: %@\nStatusCode: %i\nError: %@", url, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding], ((NSHTTPURLResponse *)response).statusCode, error);
}];

但我得到的只是每次403状态代码。通过终端中的curl进行测试工作正常。

HTTPS和NSURLConnection之间有问题吗?

0 个答案:

没有答案