我想從安全的寧靜服務獲取數據。我跟許多其他職位非常久遠iphone:didReceiveAuthenticationChallenge和canAuthenticateAgainstProtectionSpace不會被要求安全的寧靜服務
How to use NSURLConnection to connect with SSL for an untrusted cert?
但在我的情況下didReceiveAuthenticationChallenge和canAuthenticateAgainstProtectionSpace都不會被調用。
請幫助,如果你能解決問題或給我一個很好的例子來調用安全的寧靜服務。
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];
}