2

我知道如何使用NSURLConnection异步请求实现“https”。它可以使用几个委托方法来实现。现在我的问题是,我的整个应用程序都使用同步请求工作,此时无法将其更改为异步。谁能告诉我如何为同步请求实现 SSL 验证 NSURLConnection

4

1 回答 1

1

I have never found a way to. NSURLConnection sync request are extremely limited in functionality. I wrote a wrapper around NSURLConnection I call GPHTTPRequest. Should allow you do to sync request with the ability to allow self-signed and works a lot like ASIHTTPRequest, but is based on NSURLConnection instead of being the lower level CFNetwork framework. link is here:

https://github.com/daltoniam/GPHTTPRequest

also quick code example:

GPHTTPRequest* request = [GPHTTPRequest requestWithString:@"https://selfsignedURLYouwanttoaccess"];
request.allowSelfSigned = YES;
[request startSync];
NSLog(@"response: %@",[request responseString]);

also for the sake of options you can check out:

http://allseeing-i.com/ASIHTTPRequest/

https://github.com/afnetworking/afnetworking

but I would recommend GPHTTPRequest just because I wrote it and know how it works. ;) Any questions let me know.

于 2012-08-11T02:33:41.310 回答