9

ASIHTTPRequest 是否支持 HTTPS 连接?如果我尝试 HTTPS 连接,我的连接现在适用于 HTTP 连接和错误。(进入 requestFailed 并给我一个 ASIHTTPErrorRequestDomain)

-(void) getData
{

av.hidden = NO;
[av startAnimating];

NSString *urlString = [IP stringByAppendingString:@"Method1"];
NSURL *url = [NSURL URLWithString:urlString];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
NSLog(@"URL = %@",url);
[request setRequestMethod:@"POST"];
[request setPostValue:@"val1" forKey:@"key1"];
[request setPostValue:@"val2" forKey:@"key2"];
[request setDelegate:self];
[request startAsynchronous];    
}

- (void)requestFinished:(ASIHTTPRequest *)request
{
    // Use when fetching text data
    //NSString *responseString = [request responseString];

    // Use when fetching binary data
    NSData *responseData = [request responseData];
    [self parseData:responseData];

    [av stopAnimating];
    av.hidden = YES;
}


- (void)requestFailed:(ASIHTTPRequest *)request
{
    NSError *error = [request error];
    [av stopAnimating];     
    av.hidden = YES;
}

谢谢,
泰加

4

1 回答 1

17

哎呀,对不起,想通了-

[request setValidatesSecureCertificate:NO]作品供参考。

感谢这些家伙 - http://www.iphonedevsdk.com/forum/iphone-sdk-development/29417-asihttprequest-library-works-https.html

编辑:由于这得到了一些支持,我只想补充一点,这可能不是有效 SSL 证书的最佳方法。我使用的是自签名证书,所以这很好。

于 2010-04-28T14:59:23.350 回答