ASIHTTPRequest - HTTPS [英] ASIHTTPRequest - HTTPS
本文介绍了ASIHTTPRequest - HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ASIHTTPRequest 是否支持 HTTPS 连接?如果我尝试 HTTPS 连接,我的连接现在适用于 HTTP 连接和错误.(进入 requestFailed 并给我一个 ASIHTTPErrorRequestDomain)
Does ASIHTTPRequest support HTTPS connections? My connection right now works for a HTTP connection and errors if I try a HTTPS Connection. (Goes into requestFailed and gives me a 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;
}
谢谢,
泰加
推荐答案
糟糕,抱歉,搞定了 -
Whoops, sorry, figured it out -
[request setValidatesSecureCertificate:NO]
供参考.
由于这得到了一些赞成,我想补充一点,这可能不是有效 SSL 证书的最佳方法.我使用的是自签名证书,所以没问题.
Since this is getting some upvotes, I'd just like to add that this might not be the best approach for valid SSL certificates. The one I was using was a self-signed certificate, so this was fine.
这篇关于ASIHTTPRequest - HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文