無効な証明書を持つサーバー上にある Web サービスを使用していますが、とにかく応答を取得したいと考えています。それを行う方法はありますか?? サンプルコードは次のとおりです。
-(void)createHttpHeaderRequest:(serviceType)type {
NSMutableURLRequest * theRequest;
if (type==kServiceTypeTopAccessory) {
NSString * test = @"{\"GetVehicleInventory\": {\"ApplicationArea\": some Json object here}}}}}";
NSString * final = (__bridge NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)test, NULL, CFSTR(":/?#[]@!$&'()*+,;=\""), kCFStringEncodingUTF8);
NSString * sampleReq = [NSString stringWithFormat:@"https://myuntrutsedServer?XML_INPUT=%@",final];
// NSString * final = [sampleReq stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSLog(@"JSON:%@",sampleReq);
theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:sampleReq]];
}
NSLog(@"Request:%@",theRequest);
self.theConnection = [[NSURLConnection alloc]initWithRequest:theRequest delegate:self];
if (self.theConnection) {
NSLog(@"Service hit");
}
}
-(BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
NSLog(@"Error%@",error);
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
NSLog(@"Reached here");
}
didFailWithError メソッドで次のエラーが発生しています: NSLocalizedDescription=このサーバーの証明書は無効です。「209.112.58.126」を装ったサーバーに接続している可能性があり、機密情報が危険にさらされる可能性があります., NSUnderlyingError=0x6877b40 "このサーバーの証明書は無効です. 「209.112.58.126」であるため、機密情報が危険にさらされる可能性があります。", NSURLErrorFailingURLPeerTrustErrorKey=}
ありがとう、