NSURLConnection同步,异步与SSL
来源:互联网 发布:java线程笔试题 编辑:程序博客网 时间:2024/05/17 02:58
while(!finished) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDatedistantFuture]];
}
好了,现在我们看看SSL的问题,在NSURLConnnection本来有方法可以跳过ssl检查,可惜被apple无情的私有了,所以同步的数据请求肯定不行了,看看文档,只能通过异步delegate的方式了
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
{
return [protectionSpace.authenticationMethodisEqualToString:NSURLAuthenticationMethodServerTrust];
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
if ([challenge.protectionSpace.authenticationMethodisEqualToString:NSURLAuthenticationMethodServerTrust])
if ([trustedHosts containsObject:challenge.protectionSpace.host])
[challenge.sender useCredential:[NSURLCredentialcredentialForTrust:challenge.protectionSpace.serverTrust]forAuthenticationChallenge:challenge];
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}
第一个方法会根据你的URL来判断是否需要做认证
第二个方法是认证的过程,if ([trustedHosts containsObject:challenge.protectionSpace.host]),这行代码注释掉,就可以自动所有SSL通过,否则,你可以加一些Trust的hosts,其他的不通过就行了!!!
- NSURLConnection同步,异步与SSL
- NSURLConnection同步,异步与SSL
- NSURLConnection同步,异步与SSL
- NSURLConnection同步,异步与SSL
- NSURLConnection同步,异步与SSL
- NSURLConnection同步,异步与SSL
- NSURLConnection同步,异步与SSL
- NSURLConnection同步,异步与SSL
- NSURLConnection同步与异步请求
- NSURLConnection同步与异步请求
- NSURLConnection同步与异步请求
- NSURLConnection同步与异步请求
- http:nsurlconnection同步与异步
- NSURLConnection 同步异步HTTPRequest
- URLConnection同步,异步与SSL同步请求
- NSURLConnection同步和异步连接
- NSURLConnection 异步请求、同步请求
- NSURLConnection同步下载和异步下载
- iptables详解
- Win8.1如何开启隐藏Administrator账户
- 潘帕斯的境况就哈赛的卡斯高还大大撒
- 潘帕斯的开奖号噶苏大哥和撒的撒
- 回文数字之差
- NSURLConnection同步,异步与SSL
- (转载)Android:Layout_weight的深刻理解
- 条款 12: 尽量使用初始化而不要在构造函数里赋值
- OJ刷题之《筛选法选择素数》
- 展示广告的实时竞价算法浅析
- UVA - 748 Exponentiation 高精度
- nodejs npm国内镜像
- HDOJ 1724 Ellipse 自适应Simpson
- poj1197 IOI2002 Depot的公式解法