2014-06-10 1 views
0

현재 웹 페이지에 10-06-2014 16:19:11로 표시되는 백그라운드 스레드 모듈에서 작업 중입니다. 실행에 관해서는 데이터가 없습니다. inputStream을 만들고 웹 컨텐츠를 읽는 방법을 알려주시겠습니까? 이 HTTPS 링크 메시지 감안할 때 작업 가정하는 것은이 서버에 대한 인증서가 어쨌든 서버에 연결하고자 invalid.Would이다? 아래GCD가 인터넷에 배포 된 문자열을 가져 오기 위해 웹 컨텐트를 얻지 못했습니다.

하면 아래에있는 내 메시지

2014-06-10 16:46:16.292 marker[2724:7707] NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9807) 
2014-06-10 16:46:16.296 marker[2724:60b] Error = Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “dc02.cei-hk.net” which could put your confidential information at risk. 

" UserInfo=0x146be370 {NSErrorFailingURLStringKey=https://dc02.cei-hk.net:8081/GetTime.aspx, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, 
NSErrorFailingURLKey=https://dc02.csd-hk.net:8081/GetTime.aspx, NSLocalizedDescript` 

ion=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “dc02.cei-hk.net” which could put your confidential information at risk., NSUnderlyingError=0x14582870 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “dc02.csd-hk.net” which could put your confidential information at risk.", NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x14675820>}` 

입니다

dispatch_async 내 코드입니다 (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{

dispatch_async(dispatch_get_main_queue(), ^{ 
     NSURL *jsonURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://dc02.csd-hk.net:8081/GetTime.aspx",nil]]; 
     NSError *error = nil; 
     NSURLRequest *request = [NSURLRequest requestWithURL:jsonURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:120.0 ]; 

     NSData *responsedata = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error]; 
     NSString* jsonData = [[NSString alloc] initWithData:responsedata encoding:NSUTF8StringEncoding]; 

    //  NSString *json = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error]; 
     if(jsonData.length > 0) 
     { 
      NSLog(@"Text=%@", jsonData); 
      [ToastView showToastInParentView:self.view withText:jsonData withDuaration:5.0]; 
     } 
     else 
     { 
      NSLog(@"Error = %@", error); 
     } 
    }); 

}});

답변

1

URL을 확인할 수 없으므로 URL을 확인할 필요가 없습니다.

대체 서비스는 this을 참조하십시오.

+0

웹 사이트에서 json/xml 형식 –

+0

코드가 변경되지 않아서 –

+0

을 보시기 바랍니다. 사용중인 서버에 인식 된 SSL 인증서가 없습니다 (OS X의 CURL도 동일한 이유로 거부합니다.)). http를 실행하는 서비스를 찾거나 (인증서가 필요 없으므로), 확인되었거나 여기에 제안 된 것과 같은 오류를 무시하도록 설정합니다. http : //stackoverflow.com/questions/ 6792213/ignoring-invalid-server-certificates-with-uiwebview – sergio