【发布时间】:2012-07-03 14:26:27
【问题描述】:
我正在尝试从安全的宁静服务中获取数据。我关注了许多其他帖子以及
How to use NSURLConnection to connect with SSL for an untrusted cert?
但在我的情况下 didReceiveAuthenticationChallenge 和 canAuthenticateAgainstProtectionSpace 没有被调用。
如果您能解决问题,请提供帮助,或者提供一些很好的例子来调用安全的 restful 服务。
NSURL *url = [NSURL URLWithString:@"https://76.69.53.126:8443/jaxrs/tdgateway/getCountries"];
NSError * error = nil;
NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url];
[ NSURLConnection sendSynchronousRequest: urlRequest returningResponse: nil error: &error ];
NSLog(@"This is %@",url);
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
NSLog(@"This is canAuthenticateAgainstProtectionSpace");
return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
NSLog(@"This is didReceiveAuthenticationChallenge");
[[challenge sender] cancelAuthenticationChallenge:challenge];
}
【问题讨论】:
标签: iphone objective-c ios ipad ssl