安全な安らかなサービスからデータを取得しようとしています。私は他の多くの投稿をフォローしています
NSURLConnection を使用して、信頼されていない証明書の SSL に接続する方法は?
しかし、私の場合、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];
}